Don't trigger onPageChange while loading #753
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issue
#233
Description
In our application, we encountered an issue where the
onPageChange
function was continuously firing until the remote data request was complete when thetotalCount
was less than the current page. This caused the table to crash with theMaximum update depth exceeded
error.Solution
The proposed solution is to check the
isLoading
state before triggering theonPageChange
function. This approach ensures that the function is only called when the data is not loading, preventing theMaximum update depth exceeded
error.Additional Notes
Here's the codesandbox I created to demonstrate the original issue. To replicate the problem, please navigate to the last page of the table and delete the last item. Please note, the data function is mimicking an API response in order to simulate a deletion.