Answers for "pass state with history react router dom"

4

history.push with params

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

const FirstPage = props => {
    let history = useHistory();

    const someEventHandler = event => {
       history.push({
           pathname: '/secondpage',
           search: '?query=abc',
           state: { detail: 'some_value' }
       });
    };

};

export default FirstPage;
Posted by: Guest on August-26-2020
0

how to get state value from history react

history.push('/path', yourData);
Posted by: Guest on July-28-2020

Code answers related to "pass state with history react router dom"

Code answers related to "Javascript"

Browse Popular Code Answers by Language