This hook is intended to be used for reading the value of asynchronous selectors. This hook will implicitly subscribe the component to the given state.
useRecoilState(), this hook will not throw an
Promise when reading from an asynchronous selector (for the purpose of working alongside React Suspense). Instead, this hook returns a
Loadable object for the value along with the setter callback.
state: a writeable
selectorthat may have some asynchronous operations. The status of the returned loadable will depend on the status of the provided state selector.
Loadable for the current state with the interface:
state: indicates the status of the selector. Possible values are
contents: The value represented by this
Loadable. If the state is
hasValue, it is the actual value, if the state is
hasErrorit is the
Errorobject that was thrown, and if the state is
loading, then it is a
Promiseof the value.