I'm trying to use the map function in my React App and getting undefined. Returning the actual array (of objects) works, but when running map function, it returns undefined. Things work ok outside of React so I'm assuming it's syntax:
const Filter = ({ list }) => {
const filterHandler = () => {
const newList = list.map(item => {
item.id;
});
console.log(list); //this successfully logs products array
console.log(newList); //this logs undefined
};
return (
<div>
<button onClick={filterHandler}>Filter</button>
</div>
)
}
export default Filter;