hasankzl / react-flexy-table

most easy to use react table
21 stars 9 forks source link

Error while adding extra columns #4

Closed premu21 closed 4 years ago

premu21 commented 4 years ago

Error while I add few more columns and when I define their onclick function, it goes into a loop for setstate and hence doesn't work.

Following is my code in render return method:

<ReactFlexyTable data={seeks} additionalCols={this.additionalCols} sortable globalSearch />

Following function was created in the render method, and then moved to class. Still no difference.

additionalCols = [
    {
      header: "Actions",
      td: (data) => {
        return (
            <Button
              onClick={this.handleShow(data)}
              style={{ padding: "0.5rem 0.7rem" }}
            >
              <i
                className="fa fa fa-eye m-auto"
                aria-hidden="true"
                style={{ fontSize: "0.9rem" }}
              ></i>
            </Button>
        );
      },
    },
  ];

Any help would be appreciated.

hasankzl commented 4 years ago

maybe you should use arrow function

            <Button
              onClick={()=>this.handleShow(data)}
              style={{ padding: "0.5rem 0.7rem" }}
            >