Skip to content

Instantly share code, notes, and snippets.

@michaelnagy
Created August 6, 2017 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelnagy/6a572739855e520b0b9657321ddf53e8 to your computer and use it in GitHub Desktop.
Save michaelnagy/6a572739855e520b0b9657321ddf53e8 to your computer and use it in GitHub Desktop.
The full component for RenderPicker
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
@kkks7inc
Copy link

how to push the values (from 1 to 100) in a picker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment