React | Context API | Question 9

Last Updated :
Discuss
Comments

What happens if a component does not consume context?

JavaScript
const ThemeContext = React.createContext("light");

function ParentComponent() {
    return (
        <ThemeContext.Provider value="dark">
            <ChildComponent />
        </ThemeContext.Provider>
    );
}

function ChildComponent() {
    return <p>Child Component</p>;
}


It will display "dark"

It will display "light"

It will display "Child Component"

It will throw an error

Share your thoughts in the comments