0

I'm passing a jsx element when doing a redirection via router.push from registration to login.

Register:

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

In the Login constructor I have:

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

It works fine for the first time. But when I refresh the Login page, I get:

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

I have created a code sample to better illustrate my problem.

deojeff
  • 377
  • 6
  • 19
  • 1
    Please publish relevant code here, not off-site. – jmargolisvt Oct 28 '17 at 02:34
  • @jmargolisvt The two snippet above should be enough to reproduce the problem – deojeff Oct 28 '17 at 02:57
  • Have you checked this out? https://stackoverflow.com/questions/33117449/invariant-violation-objects-are-not-valid-as-a-react-child Try `console.log(typeof(this.state.intro))` in your constructor before the `if` statement. What does that say the first time and the second time? – jmargolisvt Oct 28 '17 at 03:05

0 Answers0