1import { useHistory } from "react-router-dom";
2
3const FirstPage = props => {
4    let history = useHistory();
5
6    const someEventHandler = event => {
7       history.push({
8           pathname: '/secondpage',
9           search: '?query=abc',
10           state: { detail: 'some_value' }
11       });
12    };
13
14};
15
16export default FirstPage;
17
18========================= Get Sent Params ===========================
19import { useEffect } from "react";
20import { useLocation } from "react-router-dom";
21
22const SecondPage = props => {
23    const location = useLocation();
24
25    useEffect(() => {
26       console.log(location.pathname); // result: '/secondpage'
27       console.log(location.search); // result: '?query=abc'
28       console.log(location.state.detail); // result: 'some_value'
29    }, [location]);
30
31};
32
331import { useHistory } from "react-router-dom";
2
3const FirstPage = props => {
4    let history = useHistory();
5
6    const someEventHandler = event => {
7       history.push({
8           pathname: '/secondpage',
9           search: '?query=abc',
10           state: { detail: 'some_value' }
11       });
12    };
13
14};
15
16export default FirstPage;
17
181import { useEffect } from "react";
2import { useLocation } from "react-router-dom";
3
4const SecondPage = props => {
5    const location = useLocation();
6
7    useEffect(() => {
8       console.log(location.pathname); // result: '/secondpage'
9       console.log(location.search); // result: '?query=abc'
10       console.log(location.state.detail); // result: 'some_value'
11    }, [location]);
12
13};
141import { useEffect } from "react";
2import { useLocation } from "react-router-dom";
3
4const SecondPage = props => {
5    const location = useLocation();
6
7    useEffect(() => {
8       console.log(location.pathname); // result: '/secondpage'
9       console.log(location.search); // result: '?query=abc'
10       console.log(location.state.detail); // result: 'some_value'
11    }, [location]);
12
13};
14
151import { useHistory } from "react-router-dom";
2
3const FirstPage = props => {
4    let history = useHistory();
5
6    const someEventHandler = event => {
7       history.push({
8           pathname: '/secondpage',
9           search: '?query=abc',
10           state: { detail: 'some_value' }
11       });
12    };
13
14};
15
16export default FirstPage;
17
18
19