Use radio button with React Native & Native Base
See original GitHub issueHi, I want to use Redux Form with React Native and Native Base but I’m having trouble with rendering a radio button in my app and I was hoping that someone can guide me into right direction for it.
renderRadio({ input, type, options, meta: { touched, error } }) {
const hasError = touched && error;
return (
<Form>
<Grid>
<Row>
{options.map(o => <Item key={o.value}>
<FontAwesome name={o.value === "M" ? "male" : "female"} size={25}/>
<Label>{o.title}</Label>
<Input {...input} type={type} value={o.value} checked={o.value === input.value}/>
{hasError && <Text>{error}</Text>}
</Item>)}
</Row>
</Grid>
</Form>
);
}
render() {
const { handleSubmit, fields: { email, password, passwordConfirm, gender } } = this.props;
return (
<Container style={styles.container}>
<Content>
<Form>
<Field name="email" component={this.renderField} label="Email"/>
<Field name="password" component={this.renderField} label="Password"/>
<Field name="passwordConfirm" component={this.renderField} label="Password Confirm"/>
<Field name="gender" type="radio" component={this.renderRadio} options={[
{title: 'Male', value: "M"},
{title: 'Female', value: "F"}
]}/>
{this.renderAlert()}
<Button
style={styles.button} block
action="submit"
onPress={handleSubmit(this.handleFormSubmit.bind(this))}
>
<Text>Signup</Text>
</Button>
</Form>
</Content>
</Container>
);
}
In my code, I do not see any type of radio button (neither any check sign) and get my input value from renderRadio
method as undefined.
Can anyone please help me with this?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
Radio Button
Radio Button | NativeBase | Universal Components for React and React Native · In v3 Radio can only used along with Radio. ·...
Read more >Radio buttons are not working in Native-Base
I need to use radio buttons, but they don't work. When you click nothing happens. Here is the code. import React, { Component...
Read more >Create and customize radio buttons in React Native
Learn how to build a radio button form using the React Native library and customize your radio elements for a decorated form.
Read more >native-base-docs/RadioButton.md at master
Radio Button. Radio buttons let the user select any one from a set of options. Replacing Component: React Native TouchableOpacity · Preview ios...
Read more >Radio Button · NativeBase for Web
Radio Button ; import React, { Component } from ; 'react'; import ; from 'native-base' ; export default ; class RadioButtonExample extends Component...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m not sure if this helps with the radio button but I got the Native Base checkbox working using
Hi @ckim16, this is a tricky one. See #2292 why.
When you use a
<Field type="radio" />
, Redux Form requires that you setvalue
too. So you are basically not allowed to have a radio group this way; either remove thetype
or spread the radios in the component that will render them.Example: https://codesandbox.io/s/EkggLy6m