0

Understand dependency lists out all as soon as any of them is changed will run whatever in the useEffect. Mui-data-grid pagination demo, line 75, dependency has setRowCountState which is a function:

const [rowCountState, setRowCountState] = React.useState(rowCount || 0);
React.useEffect(() => {
    setRowCountState((prevRowCountState) =>
      rowCount !== undefined ? rowCount : prevRowCountState,
    );
  }, [rowCount, setRowCountState]);

If a reference execution is a trigger, it will then create an infinite loop which needs outCallBack. But it doesn't have one. So what a function in dependency array serves?

Update The suggested answer changes the function implementation which is not the case here. I'd like to point out that Not everyone has the same intellectual level, while answer A understood by person A, it may require answer B for person B. Vice versa. Appreciate it if this is not closed.

Jeb50
  • 6,272
  • 6
  • 49
  • 87
  • Does this answer your question? [setState in React's useEffect dependency array](https://stackoverflow.com/questions/59709304/setstate-in-reacts-useeffect-dependency-array) – cSharp May 02 '22 at 00:03
  • @cSharp Thanks for the suggestion. The suggested answer use a case of `setState` function changes implementation does not apply here. – Jeb50 May 04 '22 at 23:21

0 Answers0