Skip to content
Discussion options

You must be logged in to vote

I've solved for this by setting a ref to true to track if state is being updated from "internal table state" vs external state. setFetchInfo is a state updater for table state params that results in a fetch in the parent component.

After the useTable hook:

// use this ref to keep track of updating internal table state
const tableStateUpdateRef = React.useRef(false);

React.useEffect(() => {
  tableStateUpdateRef.current = true;
  setFetchInfo({ sorted: sortBy, pageIndex, pageSize });
}, [setFetchInfo, sortBy, pageIndex, pageSize]);

// reset the page index to 0 when sorting changes
React.useEffect(() => {
  gotoPage(0);
}, [gotoPage, sortBy]);

/* reset the page index to 0 when the table …

Replies: 3 comments 8 replies

Comment options

You must be logged in to vote
5 replies
@rafaelnogueira1
Comment options

@justin-tufte
Comment options

@BrianMitchL
Comment options

@justin-tufte
Comment options

@BrianMitchL
Comment options

Answer selected by rafaelnogueira1
Comment options

You must be logged in to vote
3 replies
@BrianMitchL
Comment options

@umarluqman
Comment options

@BrianMitchL
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants