In react-router-dom v6 useHistory()
is replaced by useNavigate()
.
You can use:
import { useNavigate } from 'react-router-dom';
const navigate = useNavigate();
navigate('/home');
More Related Contents:
- How to fix missing dependency warning when using useEffect React Hook
- How to use `setState` callback on react hooks
- How to compare oldValues and newValues on React Hooks useEffect?
- Does React batch state update functions when using hooks?
- How to use callback with useState hook in react [duplicate]
- Understanding the React Hooks ‘exhaustive-deps’ lint rule
- In useEffect, what’s the difference between providing no dependency array and an empty one?
- With useEffect, how can I skip applying an effect upon the initial render?
- How to use throttle or debounce with React Hook?
- React useReducer async data fetch
- Cannot read property ‘history’ of undefined (useHistory hook of React Router 5)
- Set types on useState React Hook with TypeScript
- How to sync props to state using React hooks : setState()
- useNavigate() may be used only in the context of a component
- Testing React components that fetches data using Hooks
- React Hooks: useEffect() is called twice even if an empty array is used as an argument
- Why React useState with functional update form is needed?
- React.useState does not reload state from props
- React Hook “useState” is called in function “app” which is neither a React function component or a custom React Hook function
- React: useState or useRef?
- How do react hooks determine the component that they are for?
- Lazy initial state – What it is and how to use it?
- useReducer Action dispatched twice
- React Hooks – Modified state not reflecting immediately
- React Hooks: Why is .current null for useRef Hook?
- React hook rendering an extra time
- Property ‘value’ does not exist on type ‘never’. when use useRef hook in mui
- Passing array to useEffect dependency list
- How do I window removeEventListener using React useEffect
- React Hook useEffect has a missing dependency: ‘list’