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:
Родитель
d5ba113bb2
Коммит
461d68e656
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче