Cause 1 of 6
The value is an object, not an array.
An API returning { items: [...] } gives you an object; the array is one level down, so data.items.map(...) is what you want. console.log(Array.isArray(data), data) settles it in one line.
Browser · 6 common causes
Updated
You called a method on a value that is not the type you assumed — usually not an array, or undefined.
Uncaught TypeError: data.map is not a function
at ProductList (ProductList.jsx:14:23)
at renderWithHooks (react-dom.development.js:15486:18)Paths, line numbers and stack frames differ on every machine, and the wording is tightened between versions. The part that identifies the problem is is not a function.
Cause 1 of 6
An API returning { items: [...] } gives you an object; the array is one level down, so data.items.map(...) is what you want. console.log(Array.isArray(data), data) settles it in one line.
Cause 2 of 6
Initialise state as [] rather than leaving it undefined, so the first render maps over an empty array and produces nothing instead of throwing.
Cause 3 of 6
A NodeList from querySelectorAll has forEach but no map — convert it with Array.from(nodes). Strings have no push, plain objects have no filter. Check what the value actually is before assuming an array API.
Cause 4 of 6
Importing a namespace where a function was expected, or a named export that does not exist, gives you an object or undefined rather than a callable. Check whether the module exports a default, and match the import style.
Cause 5 of 6
JSON.parse produces plain objects: a Date comes back as a string and any class instance loses its methods. Rehydrate explicitly — new Date(value), or a factory that rebuilds the instance.
Cause 6 of 6
A local variable with the same name as an imported function, or a property assigned over a method, silently replaces it. Search for other assignments to that name in the file.
Type the boundary — TypeScript or a runtime schema check on API responses — so a wrong shape is reported at the fetch rather than at the first method call somewhere deep in a component.
Array.from(value) handles NodeLists, Sets, Maps, arguments objects and anything iterable. Spreading with [...value] does the same for iterables but not for plain array-likes without an iterator.const declarations are not callable before their line — or a circular import means the module was not finished when you read the binding.Reproducing the failure in a scratch file is usually faster than editing the real one. AltF Code is a free in-browser editor with real syntax highlighting for HTML, CSS, JavaScript, TypeScript, Python, SQL and JSON, and it runs HTML, CSS and JavaScript live in a preview panel. No install and no sign-up.
Open the editor