Reactjs
How to pass state or data in react-router v6
Pass data from one component to another component with react-router (v6) Link Component.
Published in
3 min readMar 17, 2022
The react-router is the best library to handle routing in reactjs. With a react-router, you pass state or data from one component to another component to use the react-router Link component.
Data pass more quickly in the new version of react-router (v6). For example, you can pass an object's data from one component to another.
You can play with code in code sandbox Browser base Ide.
Steps
- Pass Data
- Access data
Pass Data
- First step
- Second step
- Third step
First Step
The first step import the Link Component in react-router-dom
import { Link } from "react-router-dom";