Accepted answer

you can pass it by mentioning the props in state

    pathname: "/invoicedetails",
    state: { name: 'jack', age: 25, city: 'antwerp'}

read about it more here

and to use it in your next component you have to either wrap your component with a react-router-dom hoc withrouter or use uselocation hook they have provided.

ex- in your second component -

import {uselocation} from "react-router-dom";

function child() {
 let data = uselocation();
 console.log(data); //state would be in data.state//

Related Query

More Query from same tag