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
fix: memoize useFetchers #11247
base: dev
Are you sure you want to change the base?
fix: memoize useFetchers #11247
Conversation
|
Hi @jacobparis, Welcome, and thank you for contributing to React Router! Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once. You may review the CLA and sign it by adding your name to contributors.yml. Once the CLA is signed, the If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run. Thanks! - The Remix team |
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
Thanks for this PR - I forgot to go back and look at the implementation. I don't actually think this was stable before - it was always a new array instance . I agree it probably should be but I need to take a bit of a closer look to ensure that we're guaranteeing a brand new |
Admittedly I didn't dig through the history to see if it used to be Instead my expected behaviour was based on this tweet from @ryanflorence https://twitter.com/ryanflorence/status/1746281296475943243?s=46&t=9QWqc33eA_iECT8wUUL0VA |
Ah - yeah that tweet's referring to |
At a quick glance, I think we always do a |
useFetchers currently returns a new array on every render. This PR memoizes it based on the internal useDataRouterState which appears to be stable as long as the fetchers aren't actually changing.
The included test fails before the fix with
fetchers count: 3
and passes after the fix