react-native-paper
Version:
Material design for React Native
34 lines (31 loc) • 696 B
text/typescript
export const handlePress = ({
onPress,
value,
onValueChange,
}: {
onPress?: () => void;
value: string;
onValueChange?: (value: string) => void;
}) => {
if (onPress && onValueChange) {
console.warn(
`onPress in the scope of RadioButtonGroup will not be executed, use onValueChange instead`
);
}
onValueChange ? onValueChange(value) : onPress?.();
};
export const isChecked = ({
value,
status,
contextValue,
}: {
value: string;
status?: 'checked' | 'unchecked';
contextValue?: string;
}) => {
if (contextValue !== undefined && contextValue !== null) {
return contextValue === value ? 'checked' : 'unchecked';
} else {
return status;
}
};