-
Notifications
You must be signed in to change notification settings - Fork 1k
Lit/React – Wraps ref in a stable callback
#4335
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
Lit/React – Wraps ref in a stable callback
#4335
Conversation
🦋 Changeset detectedLatest commit: 9269fa7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
📊 Tachometer Benchmark ResultsSummaryA summary of the benchmark results will show here once they finish. ResultsThe full results of your benchmarks will show here once they finish. |
augustjk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thank you for the catch and fix! I'm suggesting a change for the changelog entry to be a bit more wordy.
augustjk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Love the additional details for the changelog.
|
It seems the benchmark check is failing, what did I break? 🙃 |
|
that's a false negative in our workflow that needs addressing. you're all good! |
I noticed in the case of providing a stable
refcallback to a wrapped React component, it was invoking it on every render. This is because the internalrefis set to an unstable function, with a new reference on every render. This was particularly problematic when using a callback to do some kind of setup/cleanup loop based on connecting/disconnecting to the DOM.To my knowledge, both React and Lit's
refcallback functionality is to ensure this only happens on connect/disconnect, or if the reference changes.E.g.
This PR ensures the intercepted
refcallback withincreateComponentis stable between renders.