Using Context Values
Dynamic Context Values
// Provides "hello world" as the MyContext value to descendants <MyContext.Provider value="hello world"> <ChildComponent /> </MyContext.Provider>
React Context objects include a
.Provider property that is a React component. It takes in a
value prop to be made available to all its descendent components.
You're a music enthusiast working on getting gigs as a DJ. You'd like to showcase your incredible music taste with a curated selection of your favorite songs, also known as a "mixtape". Since you already know how to write React code, what better use could there be for practicing React Context? This application will have you practice your React Context chops by setting up a Context globally to store mixtape viewing settings. It will include a dedicated wrapper component for its Provider that sets up React state and a state updater function.