Skip to content

Commit 7a3ffef

Browse files
authored
[react-native] Consume ReactNativeAttributePayloadFabric from ReactNativePrivateInterface (#33616)
## Summary ReactNativeAttributePayloadFabric was synced to react-native in facebook/react-native@0e42d33. We should now consume these methods from the ReactNativePrivateInterface. Moving these methods to the React Native repo gives us more flexibility to experiment with new techniques for bridging and diffing props payloads. I did have to leave some stub implementations for existing unit tests, but moved all detailed tests to the React Native repo. ## How did you test this change? * `yarn prettier` * `yarn test ReactFabric-test`
1 parent e67b4fe commit 7a3ffef

File tree

9 files changed

+82
-1014
lines changed

9 files changed

+82
-1014
lines changed

packages/react-native-renderer/src/ReactFiberConfigFabric.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import type {
1212
TouchedViewDataAtPoint,
1313
ViewConfig,
1414
} from './ReactNativeTypes';
15-
import {create, diff} from './ReactNativeAttributePayloadFabric';
1615
import {dispatchEvent} from './ReactFabricEventEmitter';
1716
import {
1817
NoEventPriority,
@@ -35,6 +34,8 @@ import {
3534
deepFreezeAndThrowOnMutationInDev,
3635
createPublicInstance,
3736
createPublicTextInstance,
37+
createAttributePayload,
38+
diffAttributePayloads,
3839
type PublicInstance as ReactNativePublicInstance,
3940
type PublicTextInstance,
4041
type PublicRootInstance,
@@ -190,7 +191,10 @@ export function createInstance(
190191
}
191192
}
192193

193-
const updatePayload = create(props, viewConfig.validAttributes);
194+
const updatePayload = createAttributePayload(
195+
props,
196+
viewConfig.validAttributes,
197+
);
194198

195199
const node = createNode(
196200
tag, // reactTag
@@ -456,7 +460,11 @@ export function cloneInstance(
456460
newChildSet: ?ChildSet,
457461
): Instance {
458462
const viewConfig = instance.canonical.viewConfig;
459-
const updatePayload = diff(oldProps, newProps, viewConfig.validAttributes);
463+
const updatePayload = diffAttributePayloads(
464+
oldProps,
465+
newProps,
466+
viewConfig.validAttributes,
467+
);
460468
// TODO: If the event handlers have changed, we need to update the current props
461469
// in the commit phase but there is no host config hook to do it yet.
462470
// So instead we hack it by updating it in the render phase.
@@ -505,7 +513,7 @@ export function cloneHiddenInstance(
505513
): Instance {
506514
const viewConfig = instance.canonical.viewConfig;
507515
const node = instance.node;
508-
const updatePayload = create(
516+
const updatePayload = createAttributePayload(
509517
{style: {display: 'none'}},
510518
viewConfig.validAttributes,
511519
);

0 commit comments

Comments
 (0)