“React History Push Search Params” Respostas de código

history.push com 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;

Precious Panda

history.push com 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]);

};
Precious Panda

História Push Pesquisa Params

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

React History Push Search Params

pathname, search
Agreeable Addax

Respostas semelhantes a “React History Push Search Params”

Perguntas semelhantes a “React History Push Search Params”

Mais respostas relacionadas para “React History Push Search Params” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código