Reactjs 为什么在react中使用history.push()时重新加载页面

Reactjs 为什么在react中使用history.push()时重新加载页面,reactjs,browser-history,Reactjs,Browser History,我这样使用history.push,但我的响应不会显示在要重新加载的页面开始列表中: Searchinp = (event) => { event.preventDefault() const props = this.props console.log(props) const searchValue = event.target.search.value props.history.push(`

我这样使用history.push,但我的响应不会显示在要重新加载的页面开始列表中:

 Searchinp = (event) => {
        event.preventDefault()
        const props = this.props
            console.log(props)
        const searchValue = event.target.search.value 
        props.history.push(`?phrase=${searchValue}`) 
       reqhandler({
         url: exporturl.getportofoliorequest(),
         method : "get",
         headers : {
             "Authorization": `Bearer ${gettoken().acctoken}`       
          },
          params : {
              lang : getLang(),
              phrase : event.target.search.value
          }
         }).then(res => {
             this.setState({
                 ...this.state,
                 resumeList : res.data.results
             })
             console.log(res.data)  
             }).catch(err => {
                 console.log("Error :" , err)
             })
        }     

请帮助我。

如果您在输入更改时更新url搜索参数,则应改为在componentDidUpdate生命周期中编写请求处理程序

Searchinp = (event) => {
   event.preventDefault()
   const props = this.props
   const searchValue = event.target.search.value 
   props.history.push(`?phrase=${searchValue}`) 

}


你能补充更多的信息吗?例如,您当前的URL是什么?当页面重新加载时,它会变成什么?我在localhost:3000/仪表板中的当前URL和成为URL的URL是locolhost:3000/仪表板?phrase=somestring,我将此用于搜索输入请求我不明白该怎么办,请提供更多信息。谢谢
requestHandler = (phrase) => {
  reqhandler({
     url: exporturl.getportofoliorequest(),
     method : "get",
     headers : {
         "Authorization": `Bearer ${gettoken().acctoken}`       
      },
      params : {
          lang : getLang(),
          phrase,
      }
     }).then(res => {
         this.setState({
             ...this.state,
             resumeList : res.data.results
         })
         console.log(res.data)  
     }).catch(err => {
         console.log("Error :" , err)
     })
}
componentDidUpdate(prevProps) {
    // get phrase from prev and current props
   if(prevPhrase !== phrase) {
        // request handler debounced
        this.debouncedRequestHandler();
   }
}