Complete the code to import a component from a separate file.
import [1] from './Header'; function App() { return <[1] />; }
React components are imported by their exact exported name, which is usually capitalized.
Complete the code to create a context for sharing data across components.
import { createContext } from 'react'; const UserContext = [1](); export default UserContext;
createContext() is used to create a new context object in React.
Fix the error in the code to properly provide context to child components.
import UserContext from './UserContext'; function App() { const user = { name: 'Alice' }; return ( <UserContext.[1] value={user}> <Dashboard /> </UserContext.[1]> ); }
The Provider component is used to supply context values to child components.
Fill both blanks to correctly use React.lazy and Suspense for code splitting.
import React, { [1] } from 'react'; const LazyComponent = [2](() => import('./LazyComponent')); function App() { return ( <React.Suspense fallback={<div>Loading...</div>}> <LazyComponent /> </React.Suspense> ); }
React.lazy is used to load components lazily, and it must be imported from React.
Fill all three blanks to create a custom hook that manages a counter state.
import { [1], [2] } from 'react'; function useCounter(initialValue) { const [count, setCount] = [3](initialValue); const increment = () => setCount(count + 1); return { count, increment }; }
useState is imported and used to create state in a custom hook. useEffect is often imported but not used here, so it's a distractor.