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:
Родитель
7468a6c903
Коммит
bcec1281c7
|
@ -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,7 +217,14 @@ class Switch extends React.Component<Props> {
|
|||
this._nativeSwitchRef &&
|
||||
this._nativeSwitchRef.setNativeProps
|
||||
) {
|
||||
this._nativeSwitchRef.setNativeProps(nativeProps);
|
||||
if (Platform.OS === 'android') {
|
||||
AndroidSwitchCommands.setNativeValue(
|
||||
this._nativeSwitchRef,
|
||||
nativeProps.value,
|
||||
);
|
||||
} else {
|
||||
this._nativeSwitchRef.setNativeProps(nativeProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче