Skip to content

Is there a hook for when loaders are running or revalidating? #12864

Closed Answered by sergiodxa
davidbielik asked this question in Q&A
Discussion options

You must be logged in to vote

With useNavigation().state you can know if the app is submitting or loading data, or if it's idle.
Unless you submit or load data with a fetcher, then you need to use fetcher.state, you can also use useFetchers() (note the plural) to get every fetcher and then get if they are loading, submitting or idle.

Finally, if you want to show a disabled or loading state until the app is hydrated, you can use the useHydrated hook from Remix Utils

let isHydrated = useHydrated()
<button disabled={!isHydrated}>Click me</button>

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by davidbielik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants