-
Notifications
You must be signed in to change notification settings - Fork 101
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
rerender for each instance of use-sound #42
Comments
Also seeing this |
I dug into this a little bit and found that additional rerenders upon calling Lines 116 to 127 in d920ebb
|
I also recognized this and I have additionally a known react issue but I don't know how to fix it in this case. This is my code:
The Warning: |
Any updates on this? |
I have same Warning, even after I update use-sound to 2.0.1 |
Any update on this? The hook is causing seemingly unnecessary rerenders :( |
I don't have the bandwidth to look into this right now, but you can avoid having multiple |
Same here, a lot of unnecessary rerenders while handling a large amount of items. Did you find a fix? |
Not a fix, but a workaround would be to use https://github.com/ds300/patch-package and comment out the lines I mentioned above: #42 (comment) (only if you aren't using that functionality). |
Ok, so I just published 4.0.0. The number of renders should be quite a bit lower now. In addition to removing the lines that @yomed found, I've made a few other tweaks that should help. In order to lower the render count, I had to ditch the When loading a component with multiple hooks, it will still re-render multiple times per hook. This is because sounds load at different times, and once the sound is loaded, we need to set it into state so that it can be interacted with. I don't expect this to be a problem in most cases, though. And if it is, you can solve it by memoizing the component down-tree (re-renders are super quick in general, they only become slow when you're rendering a lot of stuff. And we can reduce the amount of stuff we're rendering with memoization) If you have multiple hooks per component, the recommendation is still to use a sprite, as I mentioned above. This is a good idea even without considering the render count. |
When using multiple use-sound instances, the page re-renders its content depending on how many hooks are used.
F.e.:
will log
render
like 14 times. See this codesandbox.Is this the expected behaviour?
The text was updated successfully, but these errors were encountered: