Skip to content

Instantly share code, notes, and snippets.

@akellbl4
Last active June 9, 2021 06:16
Show Gist options
  • Save akellbl4/2dfaa41a0fc6b60a0120706b73e13123 to your computer and use it in GitHub Desktop.
Save akellbl4/2dfaa41a0fc6b60a0120706b73e13123 to your computer and use it in GitHub Desktop.
// pages/params.jsx
import { useEffect, useCallback } from 'react'
import { useRouter } from 'next/router'
function MyComponent() {
const { push } = useRouter()
const handleClick = useCallback(() => {
// some logic
push('/profile')
}, [push])
useEffect(() => {
if (...) {
push('/sign-in')
}
}, [push])
return <>...</>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment