Easy
What is the outcome of executing the following React code (using the useContext
hook)?
import React, { createContext, useContext } from 'react';
import MyCustomButton from 'somewhere';
const ThemeContext = createContext('light');
function ThemedButton() {
const theme = useContext(ThemeContext);
return <MyCustomButton theme={theme}>Theme: {theme}</MyCustomButton>;
}
function App() {
return (
<ThemeContext.Provider value='dark'>
<ThemedButton />
</ThemeContext.Provider>
);
}
Author: Vincent CotroStatus: PublishedQuestion passed 1187 times
Edit
Similar QuestionsMore questions about React