Skip to content

Commit 1df8cf7

Browse files
committed
Pass props through function to flatten them
1 parent e7f26c8 commit 1df8cf7

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ import type {
1818
TouchedViewDataAtPoint,
1919
} from './ReactNativeTypes';
2020

21-
import {mountSafeCallback_NOT_REALLY_SAFE} from './NativeMethodsMixinUtils';
21+
import {
22+
mountSafeCallback_NOT_REALLY_SAFE,
23+
warnForStyleProps,
24+
} from './NativeMethodsMixinUtils';
2225
import {create, diff} from './ReactNativeAttributePayload';
2326

2427
import {dispatchEvent} from './ReactFabricEventEmitter';
@@ -208,9 +211,14 @@ class ReactFabricHostComponent {
208211
}
209212

210213
setNativeProps(nativeProps: Object) {
214+
if (__DEV__) {
215+
warnForStyleProps(nativeProps, this.viewConfig.validAttributes);
216+
}
217+
const updatePayload = create(nativeProps, this.viewConfig.validAttributes);
218+
211219
const {stateNode} = this._internalInstanceHandle;
212-
if (stateNode != null) {
213-
setNativeProps(stateNode.node, nativeProps);
220+
if (stateNode != null && updatePayload != null) {
221+
setNativeProps(stateNode.node, updatePayload);
214222
}
215223
}
216224

packages/react-native-renderer/src/__tests__/ReactFabricHostComponent-test.internal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function mockRenderKeys(keyLists) {
3838

3939
const mockContainerTag = 11;
4040
const MockView = createReactNativeComponentClass('RCTMockView', () => ({
41-
validAttributes: {},
41+
validAttributes: {foo: true},
4242
uiViewClassName: 'RCTMockView',
4343
}));
4444

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

208208
const [[fooRef]] = mockRenderKeys([['foo']]);
209-
fooRef.setNativeProps({});
209+
fooRef.setNativeProps({foo: 'baz'});
210210

211211
expect(UIManager.updateView).not.toBeCalled();
212212
expect(nativeFabricUIManager.setNativeProps).toHaveBeenCalledTimes(1);

0 commit comments

Comments
 (0)