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
This commit is contained in:
Oleksandr Melnykov 2019-10-28 17:45:11 -07:00 коммит произвёл Facebook Github Bot
Родитель 7468a6c903
Коммит bcec1281c7
1 изменённых файлов: 12 добавлений и 2 удалений

Просмотреть файл

@ -15,11 +15,14 @@ const Platform = require('../../Utilities/Platform');
const React = require('react');
const StyleSheet = require('../../StyleSheet/StyleSheet');
import AndroidSwitchNativeComponent, {
Commands as AndroidSwitchCommands,
} from './AndroidSwitchNativeComponent';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {SyntheticEvent} from '../../Types/CoreEventTypes';
import type {ViewProps} from '../View/ViewPropTypes';
import SwitchNativeComponent from './SwitchNativeComponent';
import AndroidSwitchNativeComponent from './AndroidSwitchNativeComponent';
type SwitchChangeEvent = SyntheticEvent<
$ReadOnly<{|
@ -214,9 +217,16 @@ class Switch extends React.Component<Props> {
this._nativeSwitchRef &&
this._nativeSwitchRef.setNativeProps
) {
if (Platform.OS === 'android') {
AndroidSwitchCommands.setNativeValue(
this._nativeSwitchRef,
nativeProps.value,
);
} else {
this._nativeSwitchRef.setNativeProps(nativeProps);
}
}
}
_handleChange = (event: SwitchChangeEvent) => {
if (this.props.onChange != null) {