0

I have below render function in react class

class ShowDesc extends Component {

  constructor(props) {
    super(props);

    this.dataset = [{
      desc: 'This is desc',
    }, {
      desc: 'This is desc',
    }, {
      desc: 'This is desc',
    }, {
      desc: 'This is desc',
    }];
  }

  render() {
    return (
      <div>
        <ul>
          {this.dataset.map(item => {
            <Desc desc={item.desc} /> // I get below error on this line
          })}
        </ul>
      </div>
    );
  }
}

I get below error in above line

Expected an assignment or function call and instead saw an expression  no-unused-expressions

The error is does not give too much detail and I am not sure what exactly am I doing wrong in this code?

null
  • 1,112
  • 3
  • 12
  • 28
  • one issue with your code appears to be the lack of `return` before ``. Try this: " `return ` " – Dacre Denny Nov 19 '18 at 19:03
  • 1
    Your arrow function has a *function body* (you have a `{` after the `=>`), so it has no return value (since it doesn't have `return`). You probably meant to use a concise arrow function for the `map` callback, just remove the `{` and `}` from it. See the linked question for details. – T.J. Crowder Nov 19 '18 at 19:04
  • 1
    @T.J.Crowder I didn't look at that at all. That makes sense. Thanks – null Nov 19 '18 at 19:07

0 Answers0