-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add setShadowRootVersionHash to force shadowRoot to update in provide… #25332
Conversation
Changed Packages
|
Thanks for the contribution! |
@@ -102,11 +103,12 @@ export const TechDocsReaderPageContent = withTechDocsReaderProvider( | |||
const handleAppend = useCallback( | |||
(newShadowRoot: ShadowRoot) => { | |||
setShadowRoot(newShadowRoot); | |||
incShadowRootVersion(); |
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.
My best guess is that because the shadowRoot variable points to the DOM elements when the underlying DOM changes and the setShadowRoot call compares the old and new values to see if they're different they're the same so no side-effects get triggered... So we use the counter as a proxy to trigger these.
1107ba2
to
f2db271
Compare
8a1f942
to
077e1d6
Compare
…r when version changes. Signed-off-by: Sydney Achinger <sydneynicoleachinger@spotify.com>
Signed-off-by: Alex Lorenzi <alorenzi@spotify.com> Signed-off-by: Sydney Achinger <sydneynicoleachinger@spotify.com>
Signed-off-by: Alex Lorenzi <alorenzi@spotify.com> Signed-off-by: Sydney Achinger <sydneynicoleachinger@spotify.com>
Signed-off-by: Sydney Achinger <sydneynicoleachinger@spotify.com>
077e1d6
to
abdf744
Compare
Signed-off-by: Sydney Achinger <sydneynicoleachinger@spotify.com>
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.
I like this approach over the hashing due to the potential performance hit. 👍
Thank you for contributing to Backstage! The changes in this pull request will be part of the |
Add setShadowRootVersionHash to force shadowRoot to update in provider when version changes. The setShadowRoot doesn't cause a re-render because a ref is passed to it. This hash is a work around to force the update. This PR builds off the investigation done in this PR that points out the useShadowRoot hooks do not behave as expected.
....
Update: Instead of hash we are going to use a simple counter. The hash may affect performance. We really just need some type of simple state that can force the side-effects that setShadowRoot is not.
Hey, I just made a Pull Request!
✔️ Checklist
Signed-off-by
line in the message. (more info)