Reputation: 253
For some reason my onPress event is not working with React Native Paper RadioButton. I have follow instructions per docs I believe
not working:
<RadioButton.Item
label={item.templateName}
value={item._ref}
mode="android"
position="leading"
labelStyle={{textAlign: 'left'}}
onPress={()=> setValue('something')}
/>
working however if I use set state the page will render to much
<RadioButton.Item
label={item.templateName}
value={item._ref}
mode="android"
position="leading"
labelStyle={{textAlign: 'left'}}
onPress={setValue('something')}
/>
Upvotes: 1
Views: 1429
Reputation: 506
I hope this might be useful for you. Please keep below code in your file.
import this : import { RadioButton } from 'react-native-paper';
const [value, setValue] = React.useState('first');
Then keep radio buttons in group tab like below:
<RadioButton.Group onValueChange={value => setValue(value)} value={value}>
<RadioButton.Item label="First item" value="first" />
<RadioButton.Item label="Second item" value="second" />
</RadioButton.Group>
Upvotes: 1