Props not loading before Render?

Question 67 10 Dec 2016

Write answer

  • Sort By :
  • Popular
  • Recent

like @topey said i am using something like

componentDidMount() { if(!this.props.user) { //fetch or dispatch } }

Sounds like the prop is asynchronous? In that case I would usually put a check in your render method to exit early when this prop is not set then check it in the componentWillReceiveProps lifecycle event.

@topey So I tried putting an if else in there. and use componentWillReceiveProps to update state and but it doesn't seem in be firing.

And I get this.state.user is null when I refresh...

Never miss an interesting discussion,
when you sign up for Hashnode. Learn more

loading ...