Hacker News new | ask | show | jobs
UseChildFormStatus a wrapper for useFormStatus (React 18.3) (gist.github.com)
1 points by jlarky2012 1089 days ago
1 comments

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