Settings

Theme

UseChildFormStatus a wrapper for useFormStatus (React 18.3)

gist.github.com

1 points by jlarky2012 3 years ago · 1 comment

Reader

jlarky2012OP 3 years ago

I wrote this. React Experimental has added `useFormStatus` hook, which might be unintuitive if you are coming to this from something like Remix where you use something like this:

const navigation = useNavigation(); // navigation.state === "submitting"

that code works in a "global" scope, but useFormStatus only works if your component is a child of the form you want to get the status for. In practical terms, this means that you can create, say, a submit button component and use it there, but you can't easily use that state higher up, for example, if you want to add class to a pending form.

This is a pretty simple utility that will give you more control over where that state can be accessed

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection