Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Introduction to React Context for State Management


    State management is tough. It's probably one of the hardest parts about front end development, and there are a lot of different ways to solve it.

    Plain React state is easy to start with, but threading props through a deep component tree gets painful. Redux is a popular solution, but it comes with complexity and a pretty steep learning curve, and turns out to be overkill for many projects.

    React Context strikes a nice balance. It's built into React, it's easy to set up, and it makes it simple to pass props deeply through your app. Context is actually what Redux uses under the hood to pass data around!

    In this course we’ll build a simple email client. You’ll learn how to manage user login and logout using Context, and how to group related data and logic using simple wrapper components. We’ll also cover practical applications like using Context to display notifications, how to optimize performance with Context, and how to test the components that use it.



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    Dave Ceddia: Hi. My name is Dave Ceddia. Welcome to my course on state management with React Context. State management is tough. There are so many options out there. It's tough to know which to choose.

    Plain React state is simple to get started with, but passing props down through a deeply nested tree of components gets pretty painful. Redux is a popular solution, but it comes with its own complexity and steep learning curve. It turns out to be overkill for a lot of projects.

    React Context is a nice middle ground. It's built into React. It's simple to set up. It makes it easy to pass data all around your app automatically. In fact, Context is what Redux uses under the hood to pass its data around.

    In this course, I'm going to walk you through how to use Context in a scale-model version of a larger app. You'll learn how to handle a login form, save the user into state, and pass it around with Context.

    We'll go over how to wrap together related data and logic and use Context to give the rest of the app access to that data as well as be able to update it. We'll also learn some practical applications, like using Context to display notifications and how to optimize your app's performance and keep those renders passed.

    I'll go over how to test components that use Context, both the provider side and the consumer side. I'm super-glad to have you here. I hope you enjoy this course.