You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using a useMutation hook in a parent component, and passing the result down to a child component as the only prop. The child component rerenders whenever the parent rerenders. This means that the result value from useMutation keeps changing. It would be better if it were constant so that the child didn't rerender.
The text was updated successfully, but these errors were encountered:
Can you attach an example please? We do let the executeMutation callback be recreated every time, which we can fix, although a useCallback on your component would also solve this for now;
The state value should remain constant when it hasn't changed as it's simply a value from useState.
Closing this due to inactivity; We might add some useCallbacks to all execute functions in the hooks, but it doesn't look like we're actively changing the result right now.
On second thought:
The child component rerenders whenever the parent rerenders
This is normal behaviour in React though, so if you mean that the child containing useMutation updates and rerenders, that's normal even with hooks, since you still have to ensure that the update is interrupted, just like with shouldComponentUpdate, or with the new React.memo(Comp). Could that be the issue?
I'm using a useMutation hook in a parent component, and passing the result down to a child component as the only prop. The child component rerenders whenever the parent rerenders. This means that the result value from useMutation keeps changing. It would be better if it were constant so that the child didn't rerender.
The text was updated successfully, but these errors were encountered: