Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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;

Comment

history.push with params

import { useEffect } from "react";
import { useLocation } from "react-router-dom";

const SecondPage = props => {
    const location = useLocation();

    useEffect(() => {
       console.log(location.pathname); // result: '/secondpage'
       console.log(location.search); // result: '?query=abc'
       console.log(location.state.detail); // result: 'some_value'
    }, [location]);

};
Comment

history push search params

this.props.history.push({
    pathname: '/client',
    search: "?" + new URLSearchParams({clientId: clientId}).toString()
})
Comment

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;
Comment

react history push search params

pathname, search
Comment

PREVIOUS NEXT
Code Example
Javascript :: change image src onclick javascript 
Javascript :: lorem ipsum json api 
Javascript :: how to remove minutes with moment js 
Javascript :: df.saveto json 
Javascript :: react function being called every minute 
Javascript :: found page without a React Component as default export in 
Javascript :: for in 
Javascript :: js array of objects get a specific key from all objects 
Javascript :: iterate through array js 
Javascript :: how to remove character from string in javascript 
Javascript :: javascript enum 
Javascript :: javascript dir 
Javascript :: js create json array 
Javascript :: Sort big numbers from an array in javascript 
Javascript :: get first word in javascript 
Javascript :: how to make a translator in javascript 
Javascript :: Terminating timed out worker 
Javascript :: javascript kill ajax request 
Javascript :: laravel json response with error code 
Javascript :: react native gradient 
Javascript :: include other js files in a js file 
Javascript :: docker daemon bind to host and port 
Javascript :: lyrics api 
Javascript :: define function to get random value from array 
Javascript :: input type styled components 
Javascript :: electron disable scrollbar 
Javascript :: difference between var and let 
Javascript :: vue cors 
Javascript :: add regexp to antd 
Javascript :: add days in mome 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =