Use commands instead of setNativeProps for CheckBox

Summary:
As a part of the migration from setNativeProps in Fabric and Paper, we are replacing it by view commands in the Checkbox component on Android.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18451749

fbshipit-source-id: 49d786ef3383df95b10260ba2b7f68489ad31789
This commit is contained in:
Oleksandr Melnykov 2020-01-14 03:42:23 -08:00 коммит произвёл Facebook Github Bot
Родитель d5ba113bb2
Коммит 461d68e656
1 изменённых файлов: 4 добавлений и 2 удалений

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

@ -17,7 +17,9 @@ const processColor = require('../../StyleSheet/processColor');
const nullthrows = require('nullthrows');
const setAndForwardRef = require('../../Utilities/setAndForwardRef');
import AndroidCheckBoxNativeComponent from './AndroidCheckBoxNativeComponent';
import AndroidCheckBoxNativeComponent, {
Commands as AndroidCheckBoxCommands,
} from './AndroidCheckBoxNativeComponent';
import type {ViewProps} from '../View/ViewPropTypes';
import type {SyntheticEvent} from '../../Types/CoreEventTypes';
@ -141,7 +143,7 @@ class CheckBox extends React.Component<Props> {
_onChange = (event: CheckBoxEvent) => {
const value = this.props.value ?? false;
nullthrows(this._nativeRef).setNativeProps({value: value});
AndroidCheckBoxCommands.setNativeValue(nullthrows(this._nativeRef), value);
// Change the props after the native props are set in case the props
// change removes the component
this.props.onChange && this.props.onChange(event);