GuillaumeJasmin / react-table-hoc-fixed-columns

ReactTable HOC for fixed columns
MIT License
113 stars 41 forks source link

ReactTableDefaults not applying #39

Closed Gibbo3771 closed 4 years ago

Gibbo3771 commented 5 years ago

Creating overrides for the column

const columnDefaults = {
  ...ReactTableDefaults.column,
  headerClassName:
    "table__header table__header--word-wrap table__header--default",
  Cell: props => {
    const classes = {
      "text-center": true,
      "text-center": true
    };

    if (props.value === undefined) return null;
    return typeof props.value === "boolean" ? (
      <div className={mapClasses(classes)}>
        <CellBoolean value={props.value} />
      </div>
    ) : (
      <div className="text--center">{props.value}</div>
    );
  }
};

Rendering the table:


    return (
      <FixedColumnTable
        className="-striped"
        style={{ border: "none", fontSize: "0.75em" }}
        data={data}
        columns={columns}
        column={columnDefaults}
        showPagination={false}
        defaultPageSize={23}
        sortable={false}
      />
    );

Basically the column prop appears to not be doing anything, I tried it by passing the style directly like so:

      {
        Header: "eWeigh",
        accessor: "eweigh",
        headerClassName: "table__header--lighter  font--bold"
      },

This works correctly ^. So it seems trying to overwrite globally is the problem.

Am I missing something or is this a bug?

GuillaumeJasmin commented 5 years ago

Hi, Thanks for your feedback ! Yes it's a bug, I only use the current column.headerClassName: https://github.com/GuillaumeJasmin/react-table-hoc-fixed-columns/blob/e86b5bd6c54bfbbfa8f589cce66df970a54f995c/src/lib/stickyPosition/index.js#L133

I need to change with this:

headerClassName: cx(
  column.headerClassName,
  this.props.column && this.props.column.headerClassName,
  ...
)
GuillaumeJasmin commented 4 years ago

fixed on v2.1.2