Skip to content

Commit bcec128

Browse files
makovkastarfacebook-github-bot
authored andcommitted
Use commands instead of setNativeProps for AndroidSwitch
Summary: Fabric doesn't support setNativeProps, so we are using view commands instead. Changelog: [Internal] Reviewed By: JoshuaGross, TheSavior Differential Revision: D17736672 fbshipit-source-id: bb0eee9330c01751829172bbc03bfd12b1e24cad
1 parent 7468a6c commit bcec128

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Libraries/Components/Switch/Switch.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ const Platform = require('../../Utilities/Platform');
1515
const React = require('react');
1616
const StyleSheet = require('../../StyleSheet/StyleSheet');
1717

18+
import AndroidSwitchNativeComponent, {
19+
Commands as AndroidSwitchCommands,
20+
} from './AndroidSwitchNativeComponent';
21+
1822
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
1923
import type {SyntheticEvent} from '../../Types/CoreEventTypes';
2024
import type {ViewProps} from '../View/ViewPropTypes';
2125
import SwitchNativeComponent from './SwitchNativeComponent';
22-
import AndroidSwitchNativeComponent from './AndroidSwitchNativeComponent';
2326

2427
type SwitchChangeEvent = SyntheticEvent<
2528
$ReadOnly<{|
@@ -214,7 +217,14 @@ class Switch extends React.Component<Props> {
214217
this._nativeSwitchRef &&
215218
this._nativeSwitchRef.setNativeProps
216219
) {
217-
this._nativeSwitchRef.setNativeProps(nativeProps);
220+
if (Platform.OS === 'android') {
221+
AndroidSwitchCommands.setNativeValue(
222+
this._nativeSwitchRef,
223+
nativeProps.value,
224+
);
225+
} else {
226+
this._nativeSwitchRef.setNativeProps(nativeProps);
227+
}
218228
}
219229
}
220230

0 commit comments

Comments
 (0)