CheckBox is working perfect but it shown Module ‘"react-native"’ has no exported member ‘CheckBox’.
Here is my code
import React, { useState } from 'react';
import { CheckBox, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
import { Colors } from '@utils';
import { Text } from '../Text';
interface ICheckboxProps {
label: string;
onPress: () => void;
disabled?: boolean;
style?: StyleProp<ViewStyle>;
error?: boolean;
}
export const CheckBoxButton = (props: ICheckboxProps) => {
const { onPress, disabled, label, error } = props;
const [isSelected, setSelection] = useState(false);
return (
<View style={styles.container}>
<View style={styles.checkboxContainer}>
<CheckBox
value={isSelected}
onValueChange={setSelection}
labelColor={Colors.PurpleLight}
color={Colors.PurpleLight}
onPress={onPress}
disabled={disabled}
style={[styles.checkbox, error && styles.errorBorder]}
/>
</View>
<Text>{label}</Text>
</View>
);
};
I’ve tried with this:
1.Delete node_modules folder
2.run yarn add @types/react @types/react-native
- close the editor and restart everything but still don’t working
2
Answers
I make a custom checkBox, only with react-native.
As you can see, its removed from react native inbuilt package
Thats why youre thrown the error
You need to use it from this , install a new package from below
https://github.com/react-native-checkbox/react-native-checkbox