mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
bfefb22842
Upgrades the stability of Server Actions from experimental to canary. - Turns on enableAsyncActions and enableFormActions - Removes "experimental_" prefix from useOptimistic, useFormStatus, and useFormState
27 lines
585 B
JavaScript
27 lines
585 B
JavaScript
'use client';
|
|
|
|
import * as React from 'react';
|
|
import {useFormStatus} from 'react-dom';
|
|
import ErrorBoundary from './ErrorBoundary.js';
|
|
|
|
function ButtonDisabledWhilePending({action, children}) {
|
|
const {pending} = useFormStatus();
|
|
return (
|
|
<button disabled={pending} formAction={action}>
|
|
{children}
|
|
</button>
|
|
);
|
|
}
|
|
|
|
export default function Button({action, children}) {
|
|
return (
|
|
<ErrorBoundary>
|
|
<form>
|
|
<ButtonDisabledWhilePending action={action}>
|
|
{children}
|
|
</ButtonDisabledWhilePending>
|
|
</form>
|
|
</ErrorBoundary>
|
|
);
|
|
}
|