Created
August 6, 2017 14:24
-
-
Save michaelnagy/6a572739855e520b0b9657321ddf53e8 to your computer and use it in GitHub Desktop.
The full component for RenderPicker
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
import React from 'react' | |
import { View, StyleSheet, Text, Picker } from 'react-native'; | |
class RenderPicker extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
value: 'Selecione' | |
} | |
} | |
render() { | |
const { input: { onChange, value }, children, meta: { touched, error } } = this.props | |
return ( | |
touched && error ? | |
<View> | |
<Picker | |
prompt='Selecione' | |
selectedValue={ this.state.value } | |
onValueChange={ value => { | |
onChange(value) | |
this.setState({ value }) | |
} | |
}> | |
{ children } | |
</Picker> | |
<Text>É necessário selecionar uma categoria</Text> | |
</View> | |
: | |
<View> | |
<Picker | |
prompt='Selecione' | |
placeholder="Selecione" | |
selectedValue={ this.state.value } | |
onValueChange={ (value, index) => { onChange(value) | |
this.setState({ value }) | |
} | |
} | |
> | |
{ children } | |
</Picker> | |
</View> | |
) | |
} | |
} | |
const styles = StyleSheet.create({ | |
input: { | |
width:'100%' | |
} | |
}); | |
export default RenderPicker |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to push the values (from 1 to 100) in a picker