Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useMutation value should be constant #209

Closed
reverie opened this issue Mar 16, 2019 · 2 comments · Fixed by #256
Closed

useMutation value should be constant #209

reverie opened this issue Mar 16, 2019 · 2 comments · Fixed by #256
Labels
needs more info ✋ A question or report that needs more info to be addressable
Milestone

Comments

@reverie
Copy link

reverie commented Mar 16, 2019

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.

@kitten
Copy link
Member

kitten commented Mar 16, 2019

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.

@kitten kitten added this to the v1 Roadmap milestone Mar 27, 2019
@kitten kitten added the needs more info ✋ A question or report that needs more info to be addressable label Mar 27, 2019
@kitten
Copy link
Member

kitten commented Apr 7, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info ✋ A question or report that needs more info to be addressable
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants