tagged: react, nextjs
This is a collection of TILs for NextJS, a pretty awesome React Framework. You can read about it here.
I was using this to manage page navigation changes on danielsabbagh.com:
const [isLoading, setIsLoading] = useState(false);
Well, because NextJS is so great at client-side routing, I can key off of the router's asPath
to manage page changes:
const dynamicRoute = useRouter().asPath;
...
// clear related posts when loading new blog post
useEffect(() => {
setRelatedPosts([]);
setShowRelatedPosts(false);
setPostLikes(0);
setTag('');
}, [dynamicRoute]);
With this, I blew away the isLoading
silliness!