From the course: Building Production-Ready React Apps: Setup to Deployment with Firebase
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Solution: Allow components to subscribe to context changes
From the course: Building Production-Ready React Apps: Setup to Deployment with Firebase
Solution: Allow components to subscribe to context changes
(upbeat music) - [Instructor] So let's see the solutions together. The goal is for you to subscribe, allow every component to subscribe to the context changes, instead of passing the data down from top-to-bottom, and from parents to child. So as we've been doing so far, which is to pass the data from the top level down to the upload form by going through the layout actually. So this is lots of props training. So instead, we want to allow every component to subscribe to the same context change. And we're going to start with the layout. You see that here? So we're going to allow to also access this by first adding to the scope, this use context from the React library. Same. So that's going to be used context. And we also add to the scope this context object from the context file. And this is one level up. And this one is named context. So next, we can then return the value of this context. And actually, it's going to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.