我在componentDidMount請求數(shù)據(jù),然后在瀏覽器里看到我的數(shù)據(jù)請求了兩次,在網(wǎng)上也找到一些答案,但是都沒有解決問題。這是找到的一個回答:react-router3.xhashHistoryrender兩次的bug,及解決方案然后在控制臺打印出來this.props.router.location.action發(fā)現(xiàn)兩次都是POP并沒有像上面鏈接說的那樣一個是PUSH一個是POP,請問有人遇到這個問題么?是怎么解決的?數(shù)據(jù)請求:componentDidMount(){window.addEventListener('scroll',this.onScrollHandle);if(!this.state.isDraft){this.props.getRate({type:this.state.type,userId:this.state.userId});this.handlePageChange(1,3);}this.getData();console.log(this.props.router.location.action);//this.setState({provinceInfo:getProvinceInfo(this.state.provinceId)});}getData=()=>{this.props.getApp(this.state.type,this.state.userId);this.props.getSimilarApp({apptype:this.state.type});}react版本如下"react":"^15.5.4","react-dom":"^15.5.4","react-redux":"^4.4.2","react-router":"^3.0.5",
react componentDidMount 數(shù)據(jù)請求兩次
縹緲止盈
2019-08-05 23:22:44