Skip to content

Commit

Permalink
add is object chec
Browse files Browse the repository at this point in the history
  • Loading branch information
hannojg committed Jan 22, 2025
1 parent 2d205b9 commit a2cc692
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
import isArray from 'shared/isArray';

import {enableShallowPropDiffing} from 'shared/ReactFeatureFlags';
import { enableShallowPropDiffing } from 'shared/ReactFeatureFlags';

import type {AttributeConfiguration} from './ReactNativeTypes';
import type { AttributeConfiguration } from './ReactNativeTypes';

const emptyObject = {};

Expand All @@ -32,7 +32,7 @@ const emptyObject = {};
type NestedNode = Array<NestedNode> | Object;

// Tracks removed keys
let removedKeys: {[string]: boolean} | null = null;
let removedKeys: { [string]: boolean } | null = null;
let removedKeyCount = 0;

const deepDifferOptions = {
Expand Down Expand Up @@ -344,7 +344,7 @@ function diffProperties(
// case: !Object is the default case
if (enableShallowPropDiffing || defaultDiffer(prevProp, nextProp)) {
// a normal leaf has changed
(updatePayload || (updatePayload = ({}: {[string]: $FlowFixMe})))[
(updatePayload || (updatePayload = ({}: { [string]: $FlowFixMe })))[
propKey
] = nextProp;
}
Expand All @@ -363,9 +363,9 @@ function diffProperties(
const nextValue =
typeof attributeConfig.process === 'function'
? // $FlowFixMe[incompatible-use] found when upgrading Flow
attributeConfig.process(nextProp)
attributeConfig.process(nextProp)
: nextProp;
(updatePayload || (updatePayload = ({}: {[string]: $FlowFixMe})))[
(updatePayload || (updatePayload = ({}: { [string]: $FlowFixMe })))[
propKey
] = nextValue;
}
Expand Down Expand Up @@ -421,11 +421,11 @@ function diffProperties(
) {
// case: CustomAttributeConfiguration | !Object
// Flag the leaf property for removal by sending a sentinel.
(updatePayload || (updatePayload = ({}: {[string]: $FlowFixMe})))[
(updatePayload || (updatePayload = ({}: { [string]: $FlowFixMe })))[
propKey
] = null;
if (!removedKeys) {
removedKeys = ({}: {[string]: boolean});
removedKeys = ({}: { [string]: boolean });
}
if (!removedKeys[propKey]) {
removedKeys[propKey] = true;
Expand Down Expand Up @@ -478,7 +478,7 @@ function fastAddProperties(
} else {
continue;
}
} else if (typeof attributeConfig.process === 'function') {
} else if (typeof attributeConfig === 'object' && typeof attributeConfig.process === 'function') {
// An atomic prop with custom processing.
newValue = attributeConfig.process(prop);
} else if (typeof prop === 'function') {
Expand All @@ -494,7 +494,7 @@ function fastAddProperties(

if (newValue !== undefined) {
if (!payload) {
payload = ({}: {[string]: $FlowFixMe});
payload = ({}: { [string]: $FlowFixMe });
}
payload[propKey] = newValue;
continue;
Expand Down

0 comments on commit a2cc692

Please sign in to comment.