So I've been having this issue where I have an activeUser prop when a user logs in. I use it to display the users information. I persist it with localStorage, and If I navigate around it works just fine, and when I refresh keeps the user info. The issues is when I refresh when I need to use the activeUser prop on the page. The props don't seem to load before it renders the page, and I get an error of undefined.

Been working on this for quite a while, but no love. It seems to be something with the hot reloading but I'm not 100% sure.

Any Help would be awesome!

Chris

Write your answer…

like @topey said i am using something like

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

Hashnode is building a friendly and inclusive dev community. Come jump on the bandwagon!

  • 💬 A beginner friendly place

  • 🧠 Stay in the loop and grow your knowledge

  • 🍕 >500K developers share programming wisdom here

  • ❤️ Support the growing dev community!

Register ( 500k+ developers strong 👊)