react Array prototype.map expects a return value from function [Solution]

    By: Manu
    2 years ago
    Category: ReactViews: 132

    ReactJs Array prototype.map expects a return value from function or arrow function, my code was like this so change that worked for me is here

    Change this

    () => {}         to    () => ()
    

    Main difference

    import Cardbox from './Cardbox'
    
    
    const Body = ({list}) => {
      return (
        <div className="container">
            <div className="col-md-8 offset-2 mt-5">
                {list.map((item) => {
                     <Cardbox items={item}/>
                })}
            </div>
        </div>
      )
    }
    
    
    export default Body
    

    And this worked

    import Card from './Card'
    
    
    const Body = ({list}) => {
      return (
        <div className="container">
            <div className="col-md-8 offset-2 mt-5">
                {list.map((item) => (
                     <Card items={item}/>
                ))}
            </div>
        </div>
      )
    }
    
    
    export default Body