Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace useTransition with useNavigation in nprogress example #338

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions nprogress/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Outlet,
Scripts,
ScrollRestoration,
useTransition,
useNavigation,
} from "@remix-run/react";
import NProgress from "nprogress";
import nProgressStyles from "nprogress/nprogress.css";
Expand All @@ -24,14 +24,14 @@ export const meta: MetaFunction = () => ({
});

export default function App() {
const transition = useTransition();
const navigation = useNavigation();
useEffect(() => {
// when the state is idle then we can to complete the progress bar
if (transition.state === "idle") NProgress.done();
if (navigation.state === "idle") NProgress.done();
// and when it's something else it means it's either submitting a form or
// waiting for the loaders of the next location so we start it
else NProgress.start();
}, [transition.state]);
}, [navigation.state]);

return (
<html lang="en">
Expand Down