Props not loading before Render?

    Write your answer

    Start writing...

    • Sort By :
    • Popular
    • Recent

    like @topey said i am using something like

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

    Write a reply...

    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...

    Write a reply...

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

    loading ...