A common kind of “global” data is a toast or popup notification that appears in the corner of the app when some event happens. Allowing a deeply-nested component to surface a notification using props can be painful, but Context makes it much easier. In this lesson we’ll see how to dispatch a notification from a deeply-nested component and display it at the root level.
FYI: The 'before' code for this lesson is here if you need it.
how ugly this is? very ugly, everything it's a provider?!?! just DON'T! don't use context anymore
That’s just how I chose to organize the code here, to show how it could be split up. Feel free to combine them though!
You could merge the providers together into one Global provider (e.g. one provider holding state for emails, notifications, and user), or alternatively create a “wrapper” Provider which wraps its props.children with all 3 other providers.
that sounds better, I haven't experienced yet this, but an example would help others too, I guess
componentWillUnmount is not working on NotificationProvider class. Notifications still shows on logout.
I'm really enjoying this course so far, thanks Dave!
Hello there, Thanks for the great content, I learned a bunch! Here, maybe like Leox noted above, the notifications popup on the login page, which seems sort of out-of-place. Is this an out-of-scope issue for this video series, to make the notifications show-up only on the email-list page?
Thanks again