Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

TypeError: map is not a function

To solve the error, console.log the value you're calling the map method on and make sure it's a valid array.

App.js

export default function App() {
  const arr = ['one', 'two', 'three'];

  return (
    <div>
      {arr.map((element, index) => {
        return (
          <div key={index}>
            <h2>{element}</h2>
          </div>
        );
      })}
    </div>
  );
}
Source by bobbyhadz.com #
 
PREVIOUS NEXT
Tagged: #map #function
ADD COMMENT
Topic
Name
2+4 =