Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import React from 'react';
import { View } from 'react-native';
import { CheckBox } from 'react-native-elements';
const _languages = ['vi', 'vn'];
export default function CustomCheckBox(props) {
const handleOnPress = (_language, checked) => {
if (!checked) {
props.arrayHelpers.push(_language);
} else {
const idx = props.arrayHelpers.form.values.languages.indexOf(
_language,
);
props.arrayHelpers.remove(idx);
}
};
return (
<View>
{
_languages.map((_language) => {
const checked = props.arrayHelpers.form.values.languages.includes(_language);
return (
<View key={_language}>
<CheckBox
title={_language}
name={props.arrayHelpers.name}
value={_language}
checked={checked}
onPress={() => handleOnPress(_language, checked)}
/>
</View>
);
})
}
</View>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.