diffProperties() — react Function Reference
Architecture documentation for the diffProperties() function in ReactNativeAttributePayload.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 09e35162_fc97_6f1c_4f2a_776eeef412d0["diffProperties()"] 3429d3f6_3e01_954f_bb31_157d6bedf858["ReactNativeAttributePayload.js"] 09e35162_fc97_6f1c_4f2a_776eeef412d0 -->|defined in| 3429d3f6_3e01_954f_bb31_157d6bedf858 3cf42fd4_840c_03f5_8b79_ff054da06df0["addProperties()"] 3cf42fd4_840c_03f5_8b79_ff054da06df0 -->|calls| 09e35162_fc97_6f1c_4f2a_776eeef412d0 d37685ea_267f_e11c_6b6b_ddc4438e6233["clearProperties()"] d37685ea_267f_e11c_6b6b_ddc4438e6233 -->|calls| 09e35162_fc97_6f1c_4f2a_776eeef412d0 42fc5fbd_4eb6_9b1e_14bf_cd6b0d814927["diff()"] 42fc5fbd_4eb6_9b1e_14bf_cd6b0d814927 -->|calls| 09e35162_fc97_6f1c_4f2a_776eeef412d0 9f3751d1_c080_2390_b512_9565fb28c052["defaultDiffer()"] 09e35162_fc97_6f1c_4f2a_776eeef412d0 -->|calls| 9f3751d1_c080_2390_b512_9565fb28c052 42fc5fbd_4eb6_9b1e_14bf_cd6b0d814927["diff()"] 09e35162_fc97_6f1c_4f2a_776eeef412d0 -->|calls| 42fc5fbd_4eb6_9b1e_14bf_cd6b0d814927 e0202cec_6cf7_dc4a_22b4_c95465690614["restoreDeletedValuesInNestedArray()"] 09e35162_fc97_6f1c_4f2a_776eeef412d0 -->|calls| e0202cec_6cf7_dc4a_22b4_c95465690614 ea9f62a5_988f_c1db_f298_cf0ee0a3d31e["clearNestedProperty()"] 09e35162_fc97_6f1c_4f2a_776eeef412d0 -->|calls| ea9f62a5_988f_c1db_f298_cf0ee0a3d31e style 09e35162_fc97_6f1c_4f2a_776eeef412d0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-native-renderer/src/ReactNativeAttributePayload.js lines 269–443
function diffProperties(
updatePayload: null | Object,
prevProps: Object,
nextProps: Object,
validAttributes: AttributeConfiguration,
): null | Object {
let attributeConfig;
let nextProp;
let prevProp;
for (const propKey in nextProps) {
attributeConfig = validAttributes[propKey];
if (!attributeConfig) {
continue; // not a valid native prop
}
prevProp = prevProps[propKey];
nextProp = nextProps[propKey];
// functions are converted to booleans as markers that the associated
// events should be sent from native.
if (typeof nextProp === 'function') {
nextProp = (true: any);
// If nextProp is not a function, then don't bother changing prevProp
// since nextProp will win and go into the updatePayload regardless.
if (typeof prevProp === 'function') {
prevProp = (true: any);
}
}
// An explicit value of undefined is treated as a null because it overrides
// any other preceding value.
if (typeof nextProp === 'undefined') {
nextProp = (null: any);
if (typeof prevProp === 'undefined') {
prevProp = (null: any);
}
}
if (removedKeys) {
removedKeys[propKey] = false;
}
if (updatePayload && updatePayload[propKey] !== undefined) {
// Something else already triggered an update to this key because another
// value diffed. Since we're now later in the nested arrays our value is
// more important so we need to calculate it and override the existing
// value. It doesn't matter if nothing changed, we'll set it anyway.
// Pattern match on: attributeConfig
if (typeof attributeConfig !== 'object') {
// case: !Object is the default case
updatePayload[propKey] = nextProp;
} else if (
typeof attributeConfig.diff === 'function' ||
typeof attributeConfig.process === 'function'
) {
// case: CustomAttributeConfiguration
const nextValue =
typeof attributeConfig.process === 'function'
? attributeConfig.process(nextProp)
: nextProp;
updatePayload[propKey] = nextValue;
}
continue;
}
if (prevProp === nextProp) {
continue; // nothing changed
}
// Pattern match on: attributeConfig
if (typeof attributeConfig !== 'object') {
// case: !Object is the default case
if (defaultDiffer(prevProp, nextProp)) {
// a normal leaf has changed
(updatePayload || (updatePayload = ({}: {[string]: $FlowFixMe})))[
propKey
] = nextProp;
}
} else if (
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does diffProperties() do?
diffProperties() is a function in the react codebase, defined in packages/react-native-renderer/src/ReactNativeAttributePayload.js.
Where is diffProperties() defined?
diffProperties() is defined in packages/react-native-renderer/src/ReactNativeAttributePayload.js at line 269.
What does diffProperties() call?
diffProperties() calls 4 function(s): clearNestedProperty, defaultDiffer, diff, restoreDeletedValuesInNestedArray.
What calls diffProperties()?
diffProperties() is called by 3 function(s): addProperties, clearProperties, diff.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free