[NTTP]

Error Explainer

Paste a confusing error message or stack trace and get a plain-English explanation, plus what to check first.

Paste it raw, messy is fine. More of the trace usually means a more specific answer.

Optional

Optional, but it sharpens the answer. e.g. "Python, Django", "Node, Next.js", "JavaScript in the browser".

Optional

Optional. What you were doing right before this happened, helps narrow the diagnosis.

Free to try, no sign-up needed

Your text isn't stored. It's sent to Anthropic to generate your result, then discarded. Privacy

Prefer to write it yourself? Use the free prompt.

New to this? Read the guide.

What it produces

Real output from this tool, not a mock-up.

What went in

Error message or stack trace
TypeError: Cannot read properties of undefined (reading 'map') at ProductList (webpack-internal:///./src/components/ProductList.tsx:24:31) at renderWithHooks (.../react-dom.development.js:15486:18) at mountIndeterminateComponent (.../react-dom.development.js:20103:13)
Language or framework
React 18 with Next.js, TypeScript, fetching from an API route
What you were trying to do
Rendering a list of products fetched from /api/products on page load

What it means

This is a TypeError, meaning your code tried to do something with a value that isn't the type it expected. Here specifically, something is undefined when your code calls .map() on it. Arrays have a .map() method, undefined does not, so JavaScript throws. The trace shows this happens at 'ProductList (webpack-internal:///./src/components/ProductList.tsx:24:31)', which is your own component, not a library internal. That's good news, it means the bug is in code you can actually see and edit, at line 24 column 31 of ProductList.tsx. Everything below that frame (renderWithHooks, mountIndeterminateComponent, beginWork) is just React's internal machinery calling your component, it's not where the actual mistake lives. Given you're fetching from /api/products on page load, the most common cause of this exact error is that the data hasn't arrived yet when the component first renders, and whatever variable holds your product list starts out as undefined (rather than an empty array) before the fetch resolves. Another common cause with API routes specifically: the API response shape doesn't match what the component expects, for example the route returns {products: [...]} but the component tries to .map() over the whole response object instead of response.products, or the API call failed and returned an error object with no array at all. This is a textbook 'data not loaded yet' or 'wrong data shape' bug, not a framework or React 18 quirk. The fix is almost always in how you initialize state and how you access the fetched data, both of which are on or near that line 24 in ProductList.tsx.

What to check first

  • Open ProductList.tsx and look at line 24, column 31, specifically identify what variable you're calling .map() on and where it's declared or initialized (state, props, or a fetch result)
  • If that variable comes from useState, check its initial value, if it's useState() or useState(undefined) with no default, change it to useState([]) so it's an empty array before data loads
  • Log or inspect the actual response from /api/products (in the browser network tab or with a console.log) to confirm it returns an array directly or an object wrapping the array, and adjust the .map() call to match the real shape
  • Add a guard before rendering, like checking the array exists (or has length) before calling .map(), or render a loading state until the fetch completes, so the component doesn't try to map over data that hasn't arrived

When to use it

Use this when an error message tells you something is wrong but not what to do about it. Paste the message or the whole stack trace and you get a plain explanation of what it means, plus an ordered list of what to check first.

Common questions

Should I paste the whole stack trace?
Yes. The top frames name your own code and the line number, which is what makes the explanation specific rather than generic. Trimming to the first line usually leaves only the error type, which you could already read.
Does it fix the error?
It explains the error and tells you where to look, in order. It has not seen your codebase, so it cannot know that a particular API route returns a different shape on a cache miss. Treat the checks as a debugging path rather than a patch.
Why does it ask what I was doing?
Because the same error means different things in different situations. Calling map on undefined during an initial render usually points at data that has not arrived yet; the same error in an event handler usually points somewhere else entirely.
Is it free?
You can run it three times a day with no account. Signing in gives you renewing monthly credits, and this tool costs one credit per run with the one-click refinements included.

Similar tools

All Developers