Adding filter, throwing "cannot read property 'header-text' of undefined
@AllenFang thank you I have data which i am getting from REST API and i am adding columns based on data keys as below,
Issues is if i remove filter, then data is loading perfectly. But with filter its throwing error. Please help me on this, did i missed anything or is it an issue in package.
Version: "react-bootstrap-table-next": "^3.3.5", "react-bootstrap-table2-filter": "^1.3.0", "react-bootstrap-table2-paginator": "^2.1.0",
const data =[ { "name": "", "department": "", "address 1": "", "city": "", "state": "", "country": "", "last updated": "" }];
const columnsData = [];
Object.entries(data[0]).map(([key], index) => {
const header = {
"dataField": key,
"text": key.toUpperCase(),
"sort": true,
"filter": textFilter(),
"style": (cell, row, rowIndex, colIndex) => {
if (rowIndex % 2 === 0) {
return {
backgroundColor: '#F0F0F0',
fontSize: '11px'
};
}
return {
backgroundColor: 'white',
fontSize: '11px'
};
},
"headerStyle": {
fontSize: '11px',
fontWeight: 'bold'
}
}
columnsData.push(header);
});
JSX:
import filterFactory, { textFilter } from 'react-bootstrap-table2-filter'; import 'react-bootstrap-table2-filter/dist/react-bootstrap-table2-filter.min.css'
<BootstrapTable bootstrap4 keyField='last updated' data={ topic.rowData } columns={ columns } pagination={ paginationFactory()} style={{marginTop: "3px"}} filter= {filterFactory() } />
Getting Error: TypeError: Cannot read property 'name' of undefined HeaderCell.render C:/*****/node_modules/react-bootstrap-table-next/lib/src/header-cell.js:156 153 | filterElm = filterRenderer(onCustomFilter, column); 154 | } else if (filter) { 155 | filterElm = _react2.default.createElement(filter.Filter, _extends({}, filter.props, {
156 | filterState: currFilters[column.dataField], | ^ 157 | onFilter: onFilter, 158 | column: column 159 | }));
@sudheer0725 I can't reproduce this issue. please open another issue and follow the instruction to open a valid issue, note: please give an online codesandbox example so that I can reproduce and debug your case.
Note, please remember: don't mutate the data and column, in the react world, the props should be immutable, so please follow the correct to update column and data. thanks
Any solution on this?
Found this issue in codesandbox: https://codesandbox.io/s/table-smdc2?file=/src/Table.js
why the error Cannot read properties of undefined (reading 'name')
same here :(