i need help in updating columns headers dynamically , as we are passing columns list in useTable hook , for one usecase need to update columns headers list but i cant see newly added columns.
i tried by overiding allColumns instance obj by creating custom hook.
PFA codesandbox example - https://codesandbox.io/s/example-react-table-column-hide-show-5v712?file=/src/App.js
function App() {
const [state, setState] = React.useState(false);
setTimeout(() => {
columns.push({
Header: "Age",
accessor: "age"
});
setState(true);
}, 5000);
const columns = React.useMemo(
() => [
{
Header: "First Name",
accessor: "firstName"
},
{
Header: "Last Name",
accessor: "lastName"
}
],
[]
);
const data = React.useMemo(() => makeData(20), []);
return (
<Styles>
<Table columns={columns} data={data} />
</Styles>
);
}