Skip to content

Commit

Permalink
Remove ReactNative.setNativeProps
Browse files Browse the repository at this point in the history
  • Loading branch information
elicwhite committed Oct 8, 2019
1 parent 1fc56e6 commit 55910ee
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 143 deletions.
9 changes: 0 additions & 9 deletions packages/react-native-renderer/src/ReactFabric.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,6 @@ const ReactFabric: ReactFabricType = {

findNodeHandle,

setNativeProps(handle: any, nativeProps: Object) {
warningWithoutStack(
false,
'Warning: setNativeProps is not currently supported in Fabric',
);

return;
},

dispatchCommand(handle: any, command: string, args: Array<any>) {
const invalid =
handle._nativeTag == null || handle._internalInstanceHandle == null;
Expand Down
3 changes: 0 additions & 3 deletions packages/react-native-renderer/src/ReactNativeRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import NativeMethodsMixin from './NativeMethodsMixin';
import ReactNativeComponent from './ReactNativeComponent';
import {getClosestInstanceFromNode} from './ReactNativeComponentTree';
import {getInspectorDataForViewTag} from './ReactNativeFiberInspector';
import {setNativeProps} from './ReactNativeRendererSharedExports';

import {LegacyRoot} from 'shared/ReactRootTags';
import ReactSharedInternals from 'shared/ReactSharedInternals';
Expand Down Expand Up @@ -133,8 +132,6 @@ const ReactNativeRenderer: ReactNativeType = {
UIManager.dispatchViewManagerCommand(handle._nativeTag, command, args);
},

setNativeProps,

render(element: React$Element<any>, containerTag: any, callback: ?Function) {
let root = roots.get(containerTag);

Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions packages/react-native-renderer/src/ReactNativeTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ export type ReactNativeType = {
NativeComponent: typeof ReactNativeComponent,
findNodeHandle(componentOrHandle: any): ?number,
dispatchCommand(handle: any, command: string, args: Array<any>): void,
setNativeProps(handle: any, nativeProps: Object): void,
render(
element: React$Element<any>,
containerTag: any,
Expand All @@ -160,7 +159,6 @@ export type ReactFabricType = {
NativeComponent: typeof ReactNativeComponent,
findNodeHandle(componentOrHandle: any): ?number,
dispatchCommand(handle: any, command: string, args: Array<any>): void,
setNativeProps(handle: any, nativeProps: Object): void,
render(
element: React$Element<any>,
containerTag: any,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,92 +230,6 @@ describe('ReactNative', () => {
});
});

it('should be able to setNativeProps on native refs', () => {
const View = createReactNativeComponentClass('RCTView', () => ({
validAttributes: {foo: true},
uiViewClassName: 'RCTView',
}));

UIManager.updateView.mockReset();

let viewRef;
ReactNative.render(
<View
foo="bar"
ref={ref => {
viewRef = ref;
}}
/>,
11,
);

ReactNative.setNativeProps(viewRef, {});
expect(UIManager.updateView).not.toBeCalled();

ReactNative.setNativeProps(viewRef, {foo: 'baz'});
expect(UIManager.updateView).toHaveBeenCalledTimes(1);
expect(UIManager.updateView).toHaveBeenCalledWith(
expect.any(Number),
'RCTView',
{foo: 'baz'},
);
});

it('should warn and no-op if calling setNativeProps on non native refs', () => {
const View = createReactNativeComponentClass('RCTView', () => ({
validAttributes: {foo: true},
uiViewClassName: 'RCTView',
}));

class BasicClass extends React.Component {
render() {
return <React.Fragment />;
}
}

class Subclass extends ReactNative.NativeComponent {
render() {
return <View />;
}
}

const CreateClass = createReactClass({
mixins: [NativeMethodsMixin],
render: () => {
return <View />;
},
});

[BasicClass, Subclass, CreateClass].forEach(Component => {
UIManager.updateView.mockReset();

let viewRef;
ReactNative.render(
<Component
foo="bar"
ref={ref => {
viewRef = ref;
}}
/>,
11,
);

expect(UIManager.updateView).not.toBeCalled();
expect(() => {
ReactNative.setNativeProps(viewRef, {foo: 'baz'});
}).toWarnDev(
[
"Warning: setNativeProps was called with a ref that isn't a " +
'native component. Use React.forwardRef to get access ' +
'to the underlying native component',
],
{withoutStack: true},
);

expect(UIManager.updateView).not.toBeCalled();
});
});

it('should call UIManager.measure on ref.measure', () => {
const View = createReactNativeComponentClass('RCTView', () => ({
validAttributes: {foo: true},
Expand Down

0 comments on commit 55910ee

Please sign in to comment.