Back to results for “Debugging”
React › React DevTools & Debugging

What is a helpful first step when debugging an error message shown in the browser console?

Beginner

Answer

Read the error message carefully from top to bottom, since React error messages usually include the exact component name and often a helpful stack trace showing where the problem started. Searching for the exact error message online, along with checking the specific line of code it points to, usually leads directly to the fix.
// A typical React error message in the console
// Warning: Each child in a list should have a unique key prop.
// Check the render method of ProductList
// This tells you exactly which component and what the actual problem is
Real-world example A developer sees a warning about a missing key prop, reads exactly which component the warning points to, and fixes the bug within seconds by adding the missing key to the correct list item.

Common follow-ups: Why should warnings in the console not be ignored, even if the app still seems to work fine?;How do source maps help make error messages easier to understand?