Created
August 8, 2022 04:49
-
-
Save jordantwells42/0f96c7c56045d4823c6f8a4c283dba28 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useEffect } from 'react' | |
| import { useRouter } from 'next/router' | |
| // Current URL is '/' | |
| function Page() { | |
| const router = useRouter() | |
| useEffect(() => { | |
| // Always do navigations after the first render | |
| router.push('/?counter=10', undefined, { shallow: true, scroll: false }) | |
| }, []) | |
| useEffect(() => { | |
| // The counter changed! | |
| }, [router.query.counter]) | |
| } | |
| export default Page |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment