Full answer
Most beginner errors come from a small set of causes, and the messages point to them.
Too many re-renders. Calling a setter while rendering causes a new render, which calls it again. The usual cause is onClick={setCount(count + 1)}. The call runs immediately. Pass a function: onClick={() => setCount(count + 1)}. The same happens when you call a setter directly in the component body.
Objects are not valid as a React child. React can render strings, numbers, elements and arrays of them. A plain object, such as {user}, cannot be rendered. Render a field ({user.name}) or convert it (JSON.stringify). A Date also fails. Format it with toLocaleDateString.
Each child in a list should have a unique key. Add a stable key to the element returned from map. Do not use the index when items can reorder.
Rendered more hooks than during the previous render, or invalid hook call. Hooks must run in the same order each render, so no hooks inside conditions or loops, and only in components or custom hooks. Duplicate React copies in node_modules can also cause the invalid hook call error.
Cannot update a component while rendering a different component. One component's render calls another component's setter. Move that call into an effect or event handler.
Cannot read properties of undefined. Data has not arrived yet. Render a loading state or use optional chaining, but do not hide bad data silently.
Build a habit: read the first line of the message, then the first stack line from your own file, then check what runs during render. The example shows the corrected forms.
import { useState } from 'react';
const student = { name: 'Asha', joined: new Date(Date.UTC(2026, 0, 15)) };
const courses = [
{ id: 'c1', title: 'Maths' },
{ id: 'c2', title: 'Science' },
];
export default function FixedExamples() {
const [count, setCount] = useState(0);
const [data, setData] = useState(null);
return (
<div>
<button onClick={() => setCount(count + 1)}>Clicked {count}</button>
<p>
{student.name} joined on {student.joined.toLocaleDateString('en-US', { timeZone: 'UTC' })}
</p>
<ul>
{courses.map((course) => (
<li key={course.id}>{course.title}</li>
))}
</ul>
<button onClick={() => setData({ score: 82 })}>Load</button>
<p>Score: {data?.score ?? 'not loaded'}</p>
</div>
);
}This file is the corrected version of each mistake. The wrong forms are described in the answer text. The check pressed both buttons. Rendered result: <div><button>Clicked 1</button><p>Asha joined on 1/15/2026</p><ul><li>Maths</li><li>Science</li></ul><button>Load</button><p>Score: 82</p></div>
Key points
- Pass a function to onClick, not the result of calling a setter.
- Render fields or strings, not objects or Date values.
- Give list items stable keys.
- Call hooks unconditionally at the top level of components and hooks.
- Do not set one component's state during another component's render.
Common mistakes
- Writing onClick={setCount(1)} and getting an infinite loop.
- Rendering {object} directly in JSX.
- Using the index as a key for items that can be reordered.
- Calling a hook inside an if statement.
- Reading a property of data that is still null.
Follow-ups
- What causes "Invalid hook call" other than conditional hooks?
- Why does React warn when you update a different component during render?
- How do you read a React error stack to find the real cause?
Tips
- Group errors by cause. It shows you understand them instead of memorizing messages.
- Mention duplicate React copies for the invalid hook call message.
- Say you read the first stack line in your own code.