That way, your callback does not get recalculated each time your component is rendered (when the state is updated). This will prevent the client from unnecessarily redefining a function that does not change over time (since there are no dependencies).
Or, define the function outside of your component using an Inversion of Control.
Do not forget to wrap your callbacks inside of your components with a
useCallback
.That way, your callback does not get recalculated each time your component is rendered (when the state is updated). This will prevent the client from unnecessarily redefining a function that does not change over time (since there are no dependencies).
Or, define the function outside of your component using an Inversion of Control.
Thanks fr sharing