2

In my React app, I'm checking for nextProps like so:

  componentWillReceiveProps(nextProps) {
    if (nextProps.invite && nextProps.invite.status) {
    }
  }

I need the above because it's possible nextProps.invite is undefined so if I had just nextProps.invite.status I would get a JS console undefined error...

Is there a cleaner, more efficient way to write the above logic?

halfer
  • 19,471
  • 17
  • 87
  • 173
AnApprentice
  • 103,298
  • 185
  • 610
  • 989

0 Answers0