add location.replace() api ? #10800
-
// App.tsx
useEffect(()=> { fetchSomeData() },[])
const doLogin = ()=> {
location.replace('/') // fetchSomeData is reinvoke, it's expected
} |
Beta Was this translation helpful? Give feedback.
Answered by
brophdawg11
Aug 21, 2023
Replies: 1 comment 2 replies
-
This is possible via let navigate = useNavigate();
React.useEffect(() => fetchSomeData(),[])
const doLogin = () => {
navigate('/', { replace: true });
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
brophdawg11
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is possible via
useNavigate
: https://reactrouter.com/en/main/hooks/use-navigate#optionsreplace