React Fundamentals Errors
50 errors
Common react fundamentals errors and how to fix them.
50 / 50
- 1
ReferenceError: Component is not defined
You referenced a component in JSX but it was never imported or declared, so JavaScript doesn't know what it is.
- 2
Error: Invalid hook call
You called a React Hook (useState, useEffect, etc.) outside a function component or another Hook, which violates the Rules of Hooks.
- 3
Error: React Hook is called conditionally
You placed a Hook call inside an if statement or other conditional, which breaks React's ability to track Hook order across renders.
- 4
Warning: Each child in a list should have a unique key prop
You rendered a list of elements without providing a unique `key` prop to each item, which prevents React from efficiently tracking items.
- 5
Warning: Can't perform a React state update on an unmounted component
An async operation (fetch, setTimeout, promise) completed after the component unmounted and tried to call setState, indicating a memory leak.
- 6
TypeError: Cannot read properties of undefined (reading 'map')
You called `.map()` on a variable that is `undefined` — usually because data hasn't loaded yet or a prop wasn't passed.
- 7
Error: Objects are not valid as a React child
You placed a JavaScript object directly in JSX where React expects a string, number, or React element.
- 8
Error: Maximum update depth exceeded
A component is stuck in an infinite loop of state updates and re-renders, usually because setState is called during render or in a useEffect with wrong dependencies.
- 9
SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag
A component tried to return multiple sibling JSX elements without wrapping them in a parent element or Fragment.
- 10
Warning: React Hook useEffect has a missing dependency
Your useEffect references a variable that isn't in its dependency array, which can cause the effect to use stale values.
- 11
Warning: Cannot update a component while rendering a different component
A component called setState on a different component during the render phase, which React does not allow.
- 12
ReferenceError: React is not defined
JSX requires React to be in scope (in older setups) or the automatic JSX runtime to be configured. This error means neither is satisfied.
- 13
Bug: useState not updating the UI
You mutated state directly instead of calling the setter with a new value, so React didn't detect the change and didn't re-render.
- 14
Error: Too many re-renders. React limits the number of renders to prevent an infinite loop
You called a state setter function directly in the component body (not in an event handler or effect), causing an infinite render loop.
- 15
Warning: A component is changing a controlled input to be uncontrolled
An input's `value` prop changed from a defined value to `undefined` (or null), switching it from controlled to uncontrolled.
- 16
Bug: useEffect cleanup not running
The cleanup function returned from useEffect is not running, usually because it wasn't returned or the effect has wrong dependencies.
- 17
Warning: Function components cannot have string refs
You used a string ref (e.g., `ref="myRef"`) on a function component, which is a legacy API not supported in function components.
- 18
Warning: React.createElement: type is invalid -- expected a string or a function/component but got: undefined
You rendered `<SomeComponent />` but `SomeComponent` is undefined, often due to a default/named export mismatch.
- 19
Bug: Stale closure — event handler uses old state value
An event handler created in a previous render captures the state value from that render, not the current one.
- 20
Warning: Support for defaultProps will be removed from function components
You set `Component.defaultProps` on a function component, which is deprecated. Use JavaScript default parameters instead.
- 21
Warning: ReactDOM.findDOMNode is deprecated and will be removed
You called `ReactDOM.findDOMNode()` which is deprecated. Use refs attached to DOM elements instead.
- 22
Warning: componentWillMount has been renamed
You used a deprecated unsafe lifecycle method (componentWillMount, componentWillReceiveProps, componentWillUpdate).
- 23
Warning: Encountered two children with the same key
Two or more list items have the same key value, which prevents React from correctly identifying which items changed.
- 24
TypeError: Cannot read properties of null (reading 'setState')
You called `this.setState()` but `this` is null or undefined, usually because a method wasn't properly bound.
- 25
Bug: React Router shows blank page for unknown route
The user navigated to a URL that doesn't match any defined route, and no catch-all route exists.
- 26
Bug: useEffect infinite loop due to object dependency
An object or array in the dependency array is recreated on every render, causing useEffect to run in an infinite loop.
- 27
Issue: React DevTools not detecting the application
The React DevTools browser extension cannot detect React on the page, preventing component inspection.
- 28
Bug: useContext not updating when Provider value changes
The Context Provider's value prop didn't get a new reference, so consumers didn't detect the change and didn't re-render.
- 29
Error: An error occurred while loading the component. The lazy component must be a default export.
The module passed to React.lazy uses a named export but React.lazy expects a default export.
- 30
Warning: Text content did not match. Server: 'X' Client: 'Y'
The HTML rendered on the server doesn't match what React renders on the client during hydration, causing a mismatch warning.
- 31
useState stale closure in event handler
Your event handler reads a stale state value from the render in which it was created — the closure captured the old state, not the current one.
- 32
useEffect infinite loop
Your useEffect updates state on every run and its dependency array causes it to run after every render — creating an infinite loop.
- 33
Context value undefined error
You called useContext but got undefined because the component is outside the provider tree or the context default is undefined.
- 34
useRef mutation does not trigger re-render
You updated ref.current but the component did not re-render — useRef mutations are not tracked by React and do not trigger updates.
- 35
Missing key prop in list rendering
You rendered a list without key props — React cannot track which items changed, leading to bugs when items are added, removed, or reordered.
- 36
useMemo with invalid dependency causes stale value
Your useMemo dependency array is missing a value the computation uses — the memoized result is stale and does not update when the dependency changes.
- 37
useCallback with stale dependency
Your useCallback dependency array is missing a variable — the callback captures a stale value and uses it when invoked later.
- 38
JSX element not properly closed
Your JSX has an unclosed element — the transpiler cannot parse the JSX and reports a syntax error at the opening tag.
- 39
Component name not capitalized
You defined a component with a lowercase name — React treats <myComponent> as a DOM element, not a component, and renders nothing.
- 40
Invalid hook call: hooks outside function component
You called a hook outside a function component or inside a condition — React requires hooks to be called at the top level of a component.
- 41
Props type mismatch in component
You passed a prop with the wrong type — the component expects a function but got an object, or expects a string but got a number.
- 42
Fragment shorthand syntax error
You used the fragment shorthand <> incorrectly — it cannot accept attributes and must be properly closed with </>.
- 43
Missing export default for page component
Your component file is missing export default — the framework cannot find the default component to render for the route.
- 44
State update batching causes stale UI
You called setState multiple times in one handler and read state between calls — React batches updates so intermediate reads are stale.
- 45
useEffect cleanup missing causes memory leak
Your useEffect sets up a timer or subscription but has no cleanup return — the resource keeps running after the component unmounts.
- 46
Derived state stored in useState
You stored a value in useState that is computed from props — it becomes stale when props change and causes synchronization bugs.
- 47
Conditional hook call violates rules of hooks
You called a hook inside an if statement — React requires hooks to be called in the same order on every render.
- 48
Form input switching between controlled and uncontrolled
Your input value prop is undefined on first render but becomes a string later — React warns about switching from uncontrolled to controlled.
- 49
Event handler uses stale state from closure
Your onClick or onChange handler reads state that was captured when the handler was created — it does not see the latest state value.
- 50
Concurrent state updates overwrite each other
You called setState with a value computed from the current state — if multiple updates happen before re-render, only the last one applies.
No errors found.