Flashcards · React · Free
React flashcards, generated for you.
Example React study cards to learn from right now — then generate a full set from your own notes (plus a practice quiz) and export to Quizlet or Anki. Free, no account needed.
Example React flashcards
What is JSX and how does React transform it?
JSX is syntax that looks like HTML/XML but is actually JavaScript. React transforms JSX into React.createElement() calls. For example, <div>Hello</div> becomes React.createElement('div', null, 'Hello').
What is the difference between a functional component and a class component?
Functional components are JavaScript functions that return JSX and can use Hooks. Class components extend React.Component and use lifecycle methods (componentDidMount, etc.). Both can manage state and have side effects, but functional components are now preferred.
Why must component names start with a capital letter?
React treats lowercase tags as HTML elements and uppercase tags as component references. <div /> is an HTML div, but <MyComponent /> tells React to look for a user-defined component called MyComponent. Lowercase components will throw an error.
What is the key prop and why is it important in lists?
The key prop helps React identify which items have changed, been added, or removed. Use a stable, unique identifier (like id) as the key. Using array indices as keys causes bugs when list order changes because React reuses DOM nodes incorrectly.
What is the difference between state and props?
Props are immutable inputs passed from parent to child components. State is mutable data managed within a component. Props flow down; state is local. Modifying props directly is forbidden; state must be updated via setState() or the state setter function.
What does the useState Hook return and how do you use it?
useState returns an array with two elements: [currentValue, setterFunction]. Example: const [count, setCount] = useState(0). Call setCount(newValue) to update state. Each call to setState triggers a re-render with the new state value.
Why must Hooks only be called at the top level of a component, not in loops or conditionals?
React relies on the call order of Hooks to maintain state association. If Hook calls are conditional or nested, the call order changes between renders, breaking state correspondence. This causes 'Rules of Hooks' violations and unpredictable bugs.
What is the useEffect Hook and what does an empty dependency array mean?
useEffect runs side effects (data fetching, subscriptions, DOM updates) after render. useEffect(fn, []) runs fn only once after the first render. useEffect(fn, [dep]) runs when dep changes. useEffect(fn) runs after every render. Omitting the array runs the effect every render.
Why does modifying state directly (e.g., state.count = 5) not trigger a re-render?
React relies on state setter functions to detect changes via reference comparison. Direct mutation doesn't create a new reference, so React thinks nothing changed and skips re-rendering. Always use setCount() or spread syntax: setState({...state, count: 5}).
What is the difference between controlled and uncontrolled components?
A controlled component's value is tied to state and updates via onChange handlers: <input value={state} onChange={e => setState(e.target.value)} />. An uncontrolled component stores its own value in the DOM and uses refs to access it: <input ref={inputRef} />. Controlled components are preferred for form handling.
Make your own React study set
Flashcards for related topics
Studying React to build with AI? MindloomHQ turns it into real skills — structured courses, agent projects, and certificates.
Explore MindloomHQ →