Troubleshooting
TableNex is designed to be smooth, but issues can arise. This section covers common problems and their fixes.
Common Issues and Fixes
- "No data found" or "data.map is not a function" Shows Even with Data
- Cause:
data
prop is empty, undefined, or malformed. - Fix: Ensure
data
is an array of objects. - JavaScript
const data = [{ id: 1, name: "John" }]; // Not [] or {} <TableNex data={data} />
- Cause:
- keyField Error:For keys, there should be one column with 'keyField'..
- Cause: Default
keyField="id"
doesn’t match any column or data key. - Fix: Set
keyField
to a unique column in your data. - JavaScript
const data = [{ orderId: "#1001", name: "John" }]; <TableNex data={data} keyField="orderId" />
- Cause: Default
- Styles Not Applying
- Cause: CSS not loaded or overridden.
- Fix: Import
"react-tablenex/style.css"
and check for conflicts. Use!important
or Tailwind!
if needed. - JavaScript
import "react-tablenex/style.css"; <TableNex styledRows={[{ keyValue: 1, className: "!bg-red-500" }]} />
- Fixed Columns Not Working
- Cause:
fixedColumns
names don’t matchaccessor
values and it works with few first and last columns. - Fix: Use exact, case-insensitive column names.
- JavaScript
const columns = [{ accessor: "Id" }, "name"]; <TableNex fixedColumns={["id", "name"]} /> // "Id" or "id" works
- Cause:
- Expanded Rows Not Showing
- Cause:
afterRowKey
doesn’t matchkeyField
values. - Fix: Ensure
afterRowKey
aligns withkeyField
. - JavaScript
const data = [{ orderId: "#1001", name: "John" }]; <TableNex data={data} keyField="orderId" expandedRows={[{ afterRowKey: "#1001", element: <div>Details</div> }]} />
- Cause:
- Duplicate Key Error in Development
- Cause:
keyField
values aren’t unique. - Fix: Use a column with distinct values.
- JavaScript
const data = [{ id: 1 }, { id: 2 }]; // Not { id: 1 }, { id: 1 } <TableNex data={data} />
- Cause:
- Responsive Mode Not Switching
- Cause:
responsive=
not set or CSS not loaded. - Fix: Enable
responsive
and import styles. - JavaScript
import "react-tablenex/style.css"; <TableNex data={data} responsive={true} />
- Cause:
- Footer Not Displaying
- Cause:
footer
prop is empty ordata
is empty (footer only shows with data). - Fix: Add valid
footer
and ensuredata
has rows. - JavaScript
const footer = [{ cells: [{ content: "Total" }] }]; <TableNex data={[{ id: 1 }]} footer={footer} />
- Cause:
Tips
- Check console for errors in development mode—they pinpoint issues like
keyField
. - Verify prop types with TypeScript to catch mistakes early.
- Test with small datasets first to debug styling or features.