Skip to content

Commit 48f367d

Browse files
elicwhitefacebook-github-bot
authored andcommitted
Checkbox: remove cast through any
Summary: $title Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D17934095 fbshipit-source-id: 9447680dea6bdd3576164d624c9231a0f77f5c2a
1 parent 526a010 commit 48f367d

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

Libraries/Components/CheckBox/CheckBox.android.js

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const setAndForwardRef = require('../../Utilities/setAndForwardRef');
2020

2121
import type {ViewProps} from '../View/ViewPropTypes';
2222
import type {SyntheticEvent} from '../../Types/CoreEventTypes';
23-
import type {NativeComponent} from '../../Renderer/shims/ReactNative';
2423
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
2524

2625
type CheckBoxEvent = SyntheticEvent<
@@ -49,16 +48,6 @@ type CommonProps = $ReadOnly<{|
4948
testID?: ?string,
5049
|}>;
5150

52-
type NativeProps = $ReadOnly<{|
53-
...CommonProps,
54-
55-
on?: ?boolean,
56-
enabled?: boolean,
57-
tintColors: {|true: ?number, false: ?number|} | typeof undefined,
58-
|}>;
59-
60-
type CheckBoxNativeType = Class<NativeComponent<NativeProps>>;
61-
6251
type Props = $ReadOnly<{|
6352
...CommonProps,
6453

@@ -77,7 +66,7 @@ type Props = $ReadOnly<{|
7766
/**
7867
* Used to get the ref for the native checkbox
7968
*/
80-
forwardedRef?: ?React.Ref<CheckBoxNativeType>,
69+
forwardedRef?: ?React.Ref<typeof AndroidCheckBoxNativeComponent>,
8170

8271
/**
8372
* Controls the colors the checkbox has in checked and unchecked states.
@@ -141,7 +130,7 @@ type Props = $ReadOnly<{|
141130
* @keyword toggle
142131
*/
143132
class CheckBox extends React.Component<Props> {
144-
_nativeRef: ?React.ElementRef<CheckBoxNativeType> = null;
133+
_nativeRef: ?React.ElementRef<typeof AndroidCheckBoxNativeComponent> = null;
145134
_setNativeRef = setAndForwardRef({
146135
getForwardedRef: () => this.props.forwardedRef,
147136
setLocalRef: ref => {
@@ -159,7 +148,7 @@ class CheckBox extends React.Component<Props> {
159148
this.props.onValueChange(event.nativeEvent.value);
160149
};
161150

162-
getTintColors(tintColors) {
151+
_getTintColors(tintColors) {
163152
return tintColors
164153
? {
165154
true: processColor(tintColors.true),
@@ -186,7 +175,7 @@ class CheckBox extends React.Component<Props> {
186175
onResponderTerminationRequest: () => false,
187176
enabled: !disabled,
188177
on: value,
189-
tintColors: this.getTintColors(tintColors),
178+
tintColors: this._getTintColors(tintColors),
190179
style: [styles.rctCheckBox, style],
191180
};
192181
return (
@@ -206,16 +195,16 @@ const styles = StyleSheet.create({
206195
},
207196
});
208197

209-
/**
210-
* Can't use CheckBoxNativeType because it has different props
211-
*/
212-
type CheckBoxType = Class<NativeComponent<Props>>;
198+
type CheckBoxType = React.AbstractComponent<
199+
Props,
200+
React.ElementRef<typeof AndroidCheckBoxNativeComponent>,
201+
>;
213202

214-
const CheckBoxWithRef = React.forwardRef(function CheckBoxWithRef(props, ref) {
203+
const CheckBoxWithRef = React.forwardRef<
204+
Props,
205+
React.ElementRef<typeof AndroidCheckBoxNativeComponent>,
206+
>(function CheckBoxWithRef(props, ref) {
215207
return <CheckBox {...props} forwardedRef={ref} />;
216208
});
217209

218-
/* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an
219-
* error found when Flow v0.89 was deployed. To see the error, delete this
220-
* comment and run Flow. */
221210
module.exports = (CheckBoxWithRef: CheckBoxType);

0 commit comments

Comments
 (0)