John Connor
John Connor

Reputation: 11

The react shows the following error, but it lloks like everything is fine:

./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;

Upvotes: 0

Views: 58

Answers (2)

Ruan Duarte
Ruan Duarte

Reputation: 385

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

The lack of return is the probable cause of this error

Upvotes: 1

Sohan Patil
Sohan Patil

Reputation: 170

You must use 'return' statement in the map function

Upvotes: 1

Related Questions