Hide the Implementation Details of a Context Provider

Share this video with your friends

Send Tweet

A single Root component responsible for disparate data like current user, language setting, and theme will become messy and hard to work with. One way to fix this is to move related logic and data into a class, along with a Context Provider to get the data out. In this lesson we’ll group the logic and data for login, and use Context to pass it throughout the app.

Dave Ceddia
Dave Ceddia(instructor)
~ 6 years ago

Note: The 'before' code for this lesson is the code from the previous lesson.

Good Knight
Good Knight
~ 6 years ago

@Dave thanks Dave, this literally saved me when instead of trying to fix some side effects, I just used context (well understood by your narrative) and hid the implementation detail - and voila!

Rodrigo Erades
Rodrigo Erades
~ 6 years ago

Hi @Dave, I guess you miss to delete onLogin={this.handleLogin} when you convert it into a function component