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
Let's go over one solution to the React context challenge.
Resources
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
I'll walk you through how
I created the new context.
0:00
First, let's create a file in our
context folder named ThemeContext.js.
0:01
We'll create a new context using
React's createContext method.
0:10
So let's import createContext from "react".
0:15
Our context will be named ThemeContext,
so
0:19
let's write const
ThemeContext = createContext,
0:24
and set the default value to null.
0:29
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