Getting Maximun call stack In production.
See original GitHub issueI’m getting maximum call stack in production but during dev, it’s working fine. Follow is the code I’m using.
import React, { useEffect } from 'react';
import { useTable, usePagination, useSortBy, useRowSelect } from 'react-table';
import Arrow from '../../assets/img/arrow.png';
import SortArrow from '../../assets/img/downarrow.png';
export default function Table({ columns = [], data = [], _setSelected }) {
const {
getTableProps,
getTableBodyProps,
headerGroups,
// rows,
prepareRow,
pageOptions,
page,
state: { pageIndex, selectedRowPaths },
previousPage,
nextPage,
canPreviousPage,
canNextPage,
selectedFlatRows
} = useTable(
{
columns,
data,
disableSortRemove: true,
},
useSortBy,
useRowSelect,
usePagination
);
useEffect(
() => {
_setSelected(selectedFlatRows);
},
[selectedRowPaths, selectedFlatRows]
);
return (
<>
<div className="table-responsive">
<table
{...getTableProps()}
className="w-100 table table-bordered table-striped table-hover"
>
<thead>
{headerGroups.map((headerGroup) => (
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map((column) => (
<th scope="col" {...column.getHeaderProps(column.getSortByToggleProps())}>
{column.render('Header')}
{column.isSorted && <img src={SortArrow} width="18" className={column.isSortedDesc?'':'rotate-up'} alt="sorting" />}
</th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
{page.map((row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map((cell) => {
return <td {...cell.getCellProps()}>{cell.render('Cell')}</td>;
})}
</tr>
);
})}
</tbody>
</table>
</div>
{data.length > 10 && <>
<div className="text-center">
Page{' '}
<em>
{pageIndex + 1} of {pageOptions.length}
</em>
</div>
<div className="text-center">
<button
className="btn btn-primary"
onClick={() => previousPage()}
disabled={!canPreviousPage}
>
<img src={Arrow} className="previous-arrow" alt="Previous" />
</button>
<button
className="btn btn-primary"
onClick={() => nextPage()}
disabled={!canNextPage}
>
<img src={Arrow} className="next-arrow" alt="Next" />
</button>
</div>
</>}
</>
);
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:20
Top Results From Across the Web
JavaScript RangeError: Maximum Call Stack Size Exceeded
The RangeError: Maximum call stack size exceeded is thrown when a function call is made that exceeds the call stack size. This can...
Read more >"Maximum call stack exceeded" in production while dealing ...
An infinite recursion leading to "Maximum call stack exceeded", coming from inside the immer code. Expected behavior. State to be updated or at ......
Read more >Debugging "Maximum call stack size exceeded” in production
I'm using a error tracker to catch any client-side errors. Sometimes I get "Maximum call stack size exceeded" errors, which I'm not able...
Read more >JavaScript Error: Maximum Call Stack Size Exceeded
If you see the “Maximum Call Stack Size Exceeded” error, there's likely a problem with a recursive function within your JavaScript code.
Read more >Why does this code produce a "Maximum Call Stack Size ...
So this code reads right, and seems like it should execute properly, but when I ask it to run, it throws this error....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve found workaround for this issue, insipred by this conversation
First you have to set initialState.selectedRowIds but make sure it’s never recreated during render:
and re-implement selectedFlatRows’s behavior like this:
I am running into this issue as well. It runs regardless of whether or not a selection was made.