diffHydratedStyles() — react Function Reference
Architecture documentation for the diffHydratedStyles() function in ReactDOMComponent.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 67b4072c_3549_0182_2962_827546c9b302["diffHydratedStyles()"] 1e990658_7cea_75be_1f24_2399bdf9f15b["ReactDOMComponent.js"] 67b4072c_3549_0182_2962_827546c9b302 -->|defined in| 1e990658_7cea_75be_1f24_2399bdf9f15b b3ccac7d_1304_9653_2f32_5c5e2bbc637e["diffHydratedCustomComponent()"] b3ccac7d_1304_9653_2f32_5c5e2bbc637e -->|calls| 67b4072c_3549_0182_2962_827546c9b302 409bfd4f_a0a2_7b82_31de_9321ab006da0["diffHydratedGenericElement()"] 409bfd4f_a0a2_7b82_31de_9321ab006da0 -->|calls| 67b4072c_3549_0182_2962_827546c9b302 4b35d720_2de8_1dd9_f463_a3b983e3041f["createDangerousStringForStyles()"] 67b4072c_3549_0182_2962_827546c9b302 -->|calls| 4b35d720_2de8_1dd9_f463_a3b983e3041f 8c4ad254_8dbf_cbef_d7da_cf083fdc32da["normalizeMarkupForTextOrAttribute()"] 67b4072c_3549_0182_2962_827546c9b302 -->|calls| 8c4ad254_8dbf_cbef_d7da_cf083fdc32da 83fdc497_4f89_f2d6_1bd7_d810070e07dd["hasViewTransition()"] 67b4072c_3549_0182_2962_827546c9b302 -->|calls| 83fdc497_4f89_f2d6_1bd7_d810070e07dd 2424f02e_480c_609e_b8f6_8b7a23d93641["getStylesObjectFromElement()"] 67b4072c_3549_0182_2962_827546c9b302 -->|calls| 2424f02e_480c_609e_b8f6_8b7a23d93641 style 67b4072c_3549_0182_2962_827546c9b302 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-dom-bindings/src/client/ReactDOMComponent.js lines 2042–2088
function diffHydratedStyles(
domElement: Element,
value: mixed,
serverDifferences: {[propName: string]: mixed},
): void {
if (value != null && typeof value !== 'object') {
if (__DEV__) {
console.error(
'The `style` prop expects a mapping from style properties to values, ' +
"not a string. For example, style={{marginRight: spacing + 'em'}} when " +
'using JSX.',
);
}
return;
}
// First we compare the string form and see if it's equivalent.
// This lets us bail out on anything that used to pass in this form.
// It also lets us compare anything that's not parsed by this browser.
const clientValue = createDangerousStringForStyles(value);
const serverValue = domElement.getAttribute('style');
if (serverValue === clientValue) {
return;
}
const normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue);
const normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue);
if (normalizedServerValue === normalizedClientValue) {
return;
}
if (
// Trailing semi-colon means this was regenerated.
normalizedServerValue[normalizedServerValue.length - 1] === ';' &&
// TODO: Should we just ignore any style if the style as been manipulated?
hasViewTransition((domElement: any))
) {
// If this had a view transition we might have applied a view transition
// name/class and removed it. If that happens, the style attribute gets
// regenerated from the style object. This means we've lost the format
// that we sent from the server and is unable to diff it. We just treat
// it as passing even if it should be a mismatch in this edge case.
return;
}
// Otherwise, we create the object from the DOM for the diff view.
serverDifferences.style = getStylesObjectFromElement(domElement);
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does diffHydratedStyles() do?
diffHydratedStyles() is a function in the react codebase, defined in packages/react-dom-bindings/src/client/ReactDOMComponent.js.
Where is diffHydratedStyles() defined?
diffHydratedStyles() is defined in packages/react-dom-bindings/src/client/ReactDOMComponent.js at line 2042.
What does diffHydratedStyles() call?
diffHydratedStyles() calls 4 function(s): createDangerousStringForStyles, getStylesObjectFromElement, hasViewTransition, normalizeMarkupForTextOrAttribute.
What calls diffHydratedStyles()?
diffHydratedStyles() is called by 2 function(s): diffHydratedCustomComponent, diffHydratedGenericElement.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free