Complete the code to create a React context.
const ThemeContext = React.[1]();React.createContext() creates a new context object to share data without prop drilling.
Complete the code to provide context value to child components.
<ThemeContext.Provider value=[1]>
{children}
</ThemeContext.Provider>The value prop of the Provider passes the data (like theme) to children.
Fix the error in consuming context inside a functional component.
const theme = React.[1](ThemeContext);useContext is the React hook to consume context values inside components.
Fill both blanks to create a context and provide a default value.
const UserContext = React.[1]([2]);
createContext accepts a default value, often an empty object for user data.
Fill all three blanks to consume context and display a user name.
const user = React.[1](UserContext); // Assume user object has a 'name' property // Use optional chaining to avoid errors const displayName = user?.[3] || 'Guest'; return <p>Hello, [2]. Welcome back!</p>;
useContext reads the context, displayName holds the safe user name, and name accesses the property.
