Created
December 4, 2017 16:40
-
-
Save nazrdogan/b57f292d9f5c115f254094e3d13def17 to your computer and use it in GitHub Desktop.
Redux-Form Radio Button NativeBase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class RadioButton extends Component { | |
state = { | |
selectedIndex: -1 | |
}; | |
onSelected(index) { | |
this.setState({ selectedIndex: index }); | |
let selectedValue = this.props.radioValues[index]; | |
this.props.input.onChange(selectedValue); | |
} | |
render() { | |
const { selected, val, icon, label, input, changeState } = this.props; | |
return ( | |
<View style={{ flex: 1, width: "100%" }}> | |
{this.props.radioValues.map((item, index) => ( | |
<Item | |
fixedLabel | |
key={index} | |
style={{ height: 40 }} | |
onPress={() => this.onSelected(index)} | |
> | |
<Label>{item.label}</Label> | |
<Right> | |
<Radio | |
selected={this.state.selectedIndex === index ? true : false} | |
/> | |
</Right> | |
</Item> | |
))} | |
</View> | |
); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Field | |
name="check" | |
label="E-Posta" | |
radioValues={[ | |
{ label: "Erkek", value: "male" }, | |
{ label: "Kadın", value: "female" } | |
]} | |
component={RadioButton} | |
/> |
Still confused.. Please edit gist with full import and export.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am getting this
Property 'onPress' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly<{ children?: ReactNode; }>