-1
I have the following problem.
I have a Piker jam with quantity and I want from the quantity selection I get the same Textinput number defined by the quantity selection.
Component Quantity:
import React, { useState } from "react";
import { Picker, View } from "react-native";
export default function Pic() {
const [selectedValue, setSelectedValue] = useState("Selecionar");
return (
<Picker
selectedValue={selectedValue}
style={{ height: 50, width: '100%'}}
onValueChange={(itemValue, itemIndex) => setSelectedValue(itemValue)}
>
<Picker.Item label="Selecionar:" value="" />
<Picker.Item label="1" value={1}/>
<Picker.Item label="2" value={2}/>
<Picker.Item label="3" value={3}/>
<Picker.Item label="4" value={4}/>
<Picker.Item label="5" value={5}/>
<Picker.Item label="6" value={6}/>
<Picker.Item label="7" value={7}/>
<Picker.Item label="8" value={8}/>
</Picker>
);
}
Textinput component:
import React from 'react'
import { View, TextInput, StyleSheet } from 'react-native'
export default props => {
const [value, onChangeText] = React.useState('Digite aqui...');
return (
<View style={[styles.container, props.style]}>
<TextInput onChangeText={text => onChangeText(text)}
value={value} style={styles.input} />
</View>
)
}
const styles = StyleSheet.create({
container: {
width: '90%',
height: 40,
backgroundColor: '#EEE',
flexDirection: 'row',
alignItems: 'center',
borderRadius: 15,
marginLeft: 20,
},
input: {
width: '70%',
}
})
It didn’t work. Imputes don’t show up.
– Henrique Maia
Did you get to see if the map is being carried out? If you left Picker in a separate component, make sure you are "setting" the state in the right place. Also check if the inputs are being returned in the map.
– Tiago Boer Casagrande
I put as component because I’m using class on the main screen.
– Henrique Maia
export default class Home extends Component {<Contributors/>}
– Henrique Maia