Skip to content

Instantly share code, notes, and snippets.

@nazrdogan
Created December 4, 2017 16:40
Show Gist options
  • Save nazrdogan/b57f292d9f5c115f254094e3d13def17 to your computer and use it in GitHub Desktop.
Save nazrdogan/b57f292d9f5c115f254094e3d13def17 to your computer and use it in GitHub Desktop.
Redux-Form Radio Button NativeBase
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>
);
}
}
<Field
name="check"
label="E-Posta"
radioValues={[
{ label: "Erkek", value: "male" },
{ label: "Kadın", value: "female" }
]}
component={RadioButton}
/>
@anil1712
Copy link

I am getting this
Property 'onPress' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly<{ children?: ReactNode; }>

@adjieindrawan
Copy link

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