DEV Community

loading...

Discussion on: Sharing state using React's Context API

Collapse
sunnysingh profile image
Sunny Singh Author

Thanks Mike! It's ok for the data to be undefined before it's available, that's how you are able to detect loading states. I suggest you return some default content or a loading spinner in your component's render so that the rest of the component does not try to reference something like data.user.name before it's set.