Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed React Context API!
You have completed React Context API!
Preview
In this video, we'll initialize a new context using createContext(), and implement the Context API into our project.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
We'll create a new folder named
context inside the source folder.
0:00
In the context folder,
create a new file named UserContext.js.
0:03
This file structure and
naming isn't required.
0:11
I'm just doing it for
organization and maintenance reasons.
0:14
In UserContext.js,
let's first import React's
0:20
createContext method with import
{ createContext } from react.
0:25
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up