在router.push中将jsx元素传递给state

时间:2017-10-28 02:11:43

标签: javascript reactjs

我在通过router.push从注册到登录进行重定向时传递了一个jsx元素。

寄存器:

this.props.router.push({
  pathname: "/login",
  state: {
    intro: (<p>I'm a secret message from registration page</p>)
  }
})

在Login构造函数中,我有:

if (this.props.location.state && this.props.location.state.intro) {
  this.state.intro = this.props.location.state.intro
}

它第一次正常工作。但是当我刷新登录页面时,我得到:

Uncaught Error: Objects are not valid as a React child (found: object with keys {type, key, ref, props, _owner, _store}).

我创建了一个code sample来更好地说明我的问题。

0 个答案:

没有答案