functionComponent() { letfetcher = useFetcher(); letnavigation = useNavigation(); letfetcherType = getFetcherType(fetcher, navigation); useEffect(() => { if (fetcherType === "done") { // do something once the fetcher is done submitting the data } }, [fetcherType]); }
You can also use the React Hook API which let's you avoid calling useNavigation.
functionComponent() { letfetcher = useFetcher(); letfetcherType = useFetcherType(fetcher); useEffect(() => { if (fetcherType === "done") { // do something once the fetcher is done submitting the data } }, [fetcherType]); }
If you need to pass the fetcher type around, you can also import FetcherType type.
Install using
bunx shadcn@latest add @remix-utils/fetcher-type.This depends on
@remix-route/react.Derive the value of the deprecated
fetcher.typefrom the fetcher and navigation data.You can also use the React Hook API which let's you avoid calling
useNavigation.If you need to pass the fetcher type around, you can also import
FetcherTypetype.Author
Sergio XalambrÃ