From the course: Building Production-Ready React Apps: Setup to Deployment with Firebase

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Subscribe to the context changes and apply side effects in the UI

Subscribe to the context changes and apply side effects in the UI

From the course: Building Production-Ready React Apps: Setup to Deployment with Firebase

Subscribe to the context changes and apply side effects in the UI

- [Instructor] To complete the search components, the goals are first to subscribe the components to the context object, the global state. Then update the UI with a new list when the search feature is active. So in order to do that, first I'd like to make a few updates right here, so inside the context object. So, meaning that here we're going to return a memoized value. We're going to do that with use Memo, which will allow to return a new value or a memoized value, based on whether there is any change in the list of dependency. So I'm going to pass this as a dependency. And we're going to return the same right here. And also allow to return filter items, like this. And I'm going to add this as a dependency. There we go. And I'm going to pass this memoized value as the global object, global state. So now let's go back to the nav bar components. I'm going to find my nav bar component. And this is right here that I'm…

Contents