Implement experimental_useFormStatus (#26722)

Summary:
This hook reads the status of its ancestor form component, if it exists.

```js
const {pending, data, action, method} = useFormStatus();
```

It can be used to implement a loading indicator, for example. You can
think of it as a shortcut for implementing a loading state with the
useTransition hook.

For now, it's only available in the experimental channel. We'll share
docs once its closer to being stable. There are additional APIs that
will ship alongside it.

Internally it's implemented using startTransition + a context object.
That's a good way to think about its behavior, but the actual
implementation details may change in the future.

Because form elements cannot be nested, the implementation in the
reconciler does not bother to keep track of multiple nested "transition
providers". So although it's implemented using generic Fiber config
methods, it does currently make some assumptions based on React DOM's
requirements.

DiffTrain build for commit https://github.com/facebook/react/commit/540bab085d571789f4562565eebfd0db9f36345c.

Changelog: [Internal]

<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: poteto

Differential Revision: D45332971

Pulled By: tyao1

fbshipit-source-id: 12e2b5a6c71fc78efb8aedfd1907f65a816cc289
This commit is contained in:
acdlite
2023-05-02 15:35:13 -07:00
committed by Facebook GitHub Bot
parent d777e3f0c2
commit c6b6915c46
@@ -1 +1 @@
6eadbe0c4aebf68410bb48147054ee22eec4c20c
540bab085d571789f4562565eebfd0db9f36345c