-
Notifications
You must be signed in to change notification settings - Fork 48.4k
Skip setting innerHTML when HTML string has not changed #32773
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
base: main
Are you sure you want to change the base?
Conversation
Hi @lukahartwig! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
5e01f9c
to
be10b64
Compare
Even if we restore this optimization for perf and profiling purposes (#31660). I'm not sure #31600 is legit. We probably want to make sure to intentionally keep that not working and warn. That's because Another issue is that React has historically been too forgiving when it comes to where you can insert custom DOM nodes. E.g. you can insert DOM nodes as siblings of React owned nodes using a ref. That's really not supported and will lead to quirks. You can use a ref to insert manual DOM nodes into a child which also has text content, innerHTML or other children. These are all not really supported even if they happen to work sometimes. The only legit way to insert DOM nodes into a ref is if that React element has no other children nor Using a |
Maybe a warning is enough: #32774 |
@@ -565,7 +565,10 @@ function setProp( | |||
); | |||
} | |||
const nextHtml: any = value.__html; | |||
if (nextHtml != null) { | |||
if ( |
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.
we can shorten below condition to below
if (nextHtml && prevValue?.__html !== nextHtml) {
...
}
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 was trying to follow the code style here. Optional chaining is used pretty much nowhere.
#26501 introduced a regression when using
dangerouslySetInnerHTML
which causesinnerHTML
to be set even when the HTML content did not change.Resolves #31600, resolves #31660