0

./src/components/common/tableBody.jsx Line 11:11: Expected an assignment or function call and instead saw an expression no-unused-expressions

Search for the keywords to learn more about each error.

Here is the code:

import React, { Component } from "react";
import _ from "lodash";

class TableBody extends Component {
  render() {
    const { data, columns } = this.props;

    return (
      <tbody>
        {data.map((item) => (
          <tr>
            {columns.map((column) => (
              <td>{_.get(item, column.path)}</td>
            ))}
          </tr>
        ))}
      </tbody>
    );
  }
}

export default TableBody;
  • Please reproduce this error in codesandbox and add the link to the question. Thank you. – rotimi-best Apr 27 '20 at 09:14
  • Does this answer your question? [React: Expected an assignment or function call and instead saw an expression](https://stackoverflow.com/questions/45573277/react-expected-an-assignment-or-function-call-and-instead-saw-an-expression) – rotimi-best Apr 27 '20 at 09:15
  • No need to reproduce the error. This issue is a duplicate of https://stackoverflow.com/a/45573716/8817146. The answer is there. – rotimi-best Apr 27 '20 at 09:17

2 Answers2

1

You must use 'return' statement in the map function

Sohan Patil
  • 170
  • 11
1
{data.map((item) => {
  return(
    <td>{_.get(item, columns.path)}</td>
  )
})}

The lack of return is the probable cause of this error

Ruan Duarte
  • 365
  • 3
  • 16