Skip to content

Commit

Permalink
Pass props through function to flatten them
Browse files Browse the repository at this point in the history
  • Loading branch information
sammy-SC committed Dec 9, 2022
1 parent e7f26c8 commit 1df8cf7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions packages/react-native-renderer/src/ReactFabricHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import type {
TouchedViewDataAtPoint,
} from './ReactNativeTypes';

import {mountSafeCallback_NOT_REALLY_SAFE} from './NativeMethodsMixinUtils';
import {
mountSafeCallback_NOT_REALLY_SAFE,
warnForStyleProps,
} from './NativeMethodsMixinUtils';
import {create, diff} from './ReactNativeAttributePayload';

import {dispatchEvent} from './ReactFabricEventEmitter';
Expand Down Expand Up @@ -208,9 +211,14 @@ class ReactFabricHostComponent {
}

setNativeProps(nativeProps: Object) {
if (__DEV__) {
warnForStyleProps(nativeProps, this.viewConfig.validAttributes);
}
const updatePayload = create(nativeProps, this.viewConfig.validAttributes);

const {stateNode} = this._internalInstanceHandle;
if (stateNode != null) {
setNativeProps(stateNode.node, nativeProps);
if (stateNode != null && updatePayload != null) {
setNativeProps(stateNode.node, updatePayload);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function mockRenderKeys(keyLists) {

const mockContainerTag = 11;
const MockView = createReactNativeComponentClass('RCTMockView', () => ({
validAttributes: {},
validAttributes: {foo: true},
uiViewClassName: 'RCTMockView',
}));

Expand Down Expand Up @@ -206,7 +206,7 @@ describe('setNativeProps', () => {
} = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface');

const [[fooRef]] = mockRenderKeys([['foo']]);
fooRef.setNativeProps({});
fooRef.setNativeProps({foo: 'baz'});

expect(UIManager.updateView).not.toBeCalled();
expect(nativeFabricUIManager.setNativeProps).toHaveBeenCalledTimes(1);
Expand Down

0 comments on commit 1df8cf7

Please sign in to comment.