Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何在生命周期方法中呈现新的JSX?_Reactjs_Redux_React Router - Fatal编程技术网

Reactjs 如何在生命周期方法中呈现新的JSX?

Reactjs 如何在生命周期方法中呈现新的JSX?,reactjs,redux,react-router,Reactjs,Redux,React Router,当我的新状态映射到我的道具时,我希望有条件地呈现一个新的JSX元素,如下所示 async componentWillReceiveProps(nextProps: props) { if (nextProps.selectedStatement) { if (this.statementIsFiltered()) { return <Redirect to={location}/> } } 异步组件将接收props(nextrops:props){ if(nextr

当我的新状态映射到我的道具时,我希望有条件地呈现一个新的JSX元素,如下所示

async componentWillReceiveProps(nextProps: props) {
 if (nextProps.selectedStatement) {
  if (this.statementIsFiltered()) {
    return <Redirect to={location}/>
 }
}
异步组件将接收props(nextrops:props){
if(nextrops.selectedStatement){
if(this.statementIsFiltered()){
返回
}
}
在渲染时执行此操作

render() {

  if (this.props.selectedStatement && this.statementIsFiltered()) return <Redirect to={location} />

  return (
    <div>
      Rest of your code
    </div>
  )
}
render(){
if(this.props.selectedStatement&&this.statementIsFiltered())返回
返回(
代码的其余部分
)
}
在渲染时执行此操作

render() {

  if (this.props.selectedStatement && this.statementIsFiltered()) return <Redirect to={location} />

  return (
    <div>
      Rest of your code
    </div>
  )
}
render(){
if(this.props.selectedStatement&&this.statementIsFiltered())返回
返回(
代码的其余部分
)
}

我不认为这是一条路。
反应路由器
v4

试一试


用路由器增强你的组件(你的组件)

我认为这不是一个好办法。
react router
v4

试一试

使用路由器增强您的组件(您的组件)