Answers for "how to pass an object through history prop in reactjs"

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
4

react router history push parameter

this.props.history.push({
  pathname: '/template',
  search: '?query=abc',
  state: { detail: response.data }
})
Posted by: Guest on March-17-2020
0

how to pass an object through history prop in reactjs

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;


OR

this.props.history.push({
  pathname: '/template',
  search: '?query=abc',
  state: { detail: response.data }
})
Posted by: Taylor Swift on April-19-2022

Code answers related to "how to pass an object through history prop in reactjs"

Code answers related to "Javascript"

Browse Popular Code Answers by Language