dillon1000/react

Commit

Scaffolding for useFormState (#27270)

This exposes, but does not yet implement, a new experimental API called
useFormState. It's gated behind the enableAsyncActions flag.

useFormState has a similar signature to useReducer, except instead of a
reducer it accepts an (async) action function. React will wait until the
promise resolves before updating the state:

```js
async function action(prevState, payload) {
  // ..
}
const [state, dispatch] = useFormState(action, initialState)
```

When used in combination with Server Actions, it will also support
progressive enhancement — a form that is submitted before it has
hydrated will have its state transferred to the next page. However, like
the other action-related hooks, it works with fully client-driven
actions, too.
Browse files
Changed paths15 files
First-parent comparison
M .eslintrc.js ModifiedM packages/react-dom-bindings/src/shared/ReactDOMFormActions.js ModifiedM packages/react-dom/index.classic.fb.js ModifiedM packages/react-dom/index.experimental.js ModifiedM packages/react-dom/index.js ModifiedM packages/react-dom/index.modern.fb.js ModifiedM packages/react-dom/server-rendering-stub.js ModifiedM packages/react-dom/src/__tests__/ReactDOMFizzForm-test.js ModifiedM packages/react-dom/src/__tests__/ReactDOMForm-test.js ModifiedM packages/react-dom/src/client/ReactDOM.js ModifiedM packages/react-dom/src/server/ReactDOMServerRenderingStub.js ModifiedM packages/react-reconciler/src/ReactFiberHooks.js ModifiedM packages/react-reconciler/src/ReactInternalTypes.js ModifiedM packages/react-server/src/ReactFizzHooks.js ModifiedM scripts/error-codes/codes.json Modified
Patch

Files changed

Rendering syntax-highlighted changes…