Note: You can only use () function inside the component page that already listed on your project route, or simply use the withRouter() HOC if the component is not available in the route list. Let’s say we want to move to the dashboard page, all we need to do is: class M圜omponent extends React.Component ) It takes the first argument as a destination path and a second argument as the state. The history.push() function belongs to react-router-dom and used to move from the current page to another one. In this article, you will learn how to use in your react project. Use the following command from a terminal window to generate the project directory, then navigate inside the project directory and install required dependencies to add React Router v6 library: npx create-react-app react-router-v6-example cd react-router-v6-example yarn add history react-router-domnext.
0 Comments
Leave a Reply. |