useAction
A hook to retrieve the result of a route's action. Use this in the route component of a route with an action prop.
import { useAction } from 'react-sprout';
let action = useAction();
- Name
action- Type
- any
- Description
The result of the action, or
undefinedif the route has no action, or if this navigation did not run one.
A route can always be navigated to without an action having run. Make sure
the component using useAction can also handle an undefined result.
Suspense
While the action is busy, useAction will suspend your component. Use a react suspense boundary somewhere up in the component tree to display a fallback user interface.
If the action throws an error, it will not be thrown from useAction. Use
the useErrors hook to read action errors instead.