-
-
Save Uvacoder/4397f2d1dcdbd77385b62141b00f3402 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