Im new to react-native. I have created these selectors. Im stumped on how to make the default selection the first 2 items in each selector. So “Home Game” and “League” selected by default. Any ideas?
Here is my code:
`const SelectorBar: React.FC = ({
value,
labels,
onChangeValue,
style,
}) => {
return (
<View style={[styles.root, style]}>
{
labels && labels.map((item, index) => {
const [userOption, setUserOption] = useState(data[0].value);
const isSelected = useState
const isSelected = item === value;
const backgroundColor = isSelected ? colors.GREY.primary : ‘transparent’;
return (
<Pressable style={[styles.tab, { backgroundColor }]} key={index} onPress={() => { onChangeValue && onChangeValue(item); }}>
<CustomText>{item}</CustomText>
</Pressable>
);
})
}
</View>
);
};
const styles = StyleSheet.create({
root: {
flexDirection: ‘row’,
borderWidth: wp(0.5),
borderColor: colors.GREY.primary,
height: wp(10),
borderRadius: wp(2),
},
tab: {
flex: 1,
justifyContent: ‘center’,
alignItems: ‘center’,
},
});
`
Tried to set the pressed state as active, but no luck.