react 项目开发中的问题汇总

react-router url参数更新 但是页面不更新的解决办法
eg: problemsManage/view 切换到 problemsManage/add 页面参数更新,但是页面没有更新。

使用 componentWillReceiveProps(newProps) 函数,当 props 改变时,我们就可以在该函数中通过 newProps拿到新的url参数,来进行更新。

componentWillReceiveProps(newProps) {
  const id = newProps.match.params.id;
  // 一些操作
}

你可能感兴趣的:(react 项目开发中的问题汇总)