I am using RNPickerSelect and trying to put dynamic value to the dropdown list. Error i am getting as 'Unexpected token, expected ","'. Below is the script that i am using.
const RegisterScreen = ({ navigation }) => {
const [value, setValue] = useState(undefined);
useEffect(() => {
var value = AsyncStorage.getItem('userData').then(
(values) => {
setValue(JSON.parse(values))
});
}, [])
if (!value) {
return null;
}
return (
<Background>
<View style={styles.mainPanel}>
<View styles={styles.heading}>
<Header>
<TouchableOpacity onPress={() => navigation.navigate('Dashboard')}><ImageBackground source={require('../assets/arrow_back.png')} style={styles.backButton}></ImageBackground></TouchableOpacity>
Fund Transfer
</Header>
</View>
<View style={styles.mainviewBackground}>
<View>
<Text>Debit From Account :</Text>
<RNPickerSelect
onValueChange={(value) => console.log(value)}
items={[
{ label: { value.accounts1 }, value: { value.accounts1 } }
]}
/>
</View>
Inside RNPickerSelectm items value I am trying to fetch the data from the values.
Hard to say when the shape of the values is not provided. But if they are objects, you could try:
items={[
{ label: ...value.accounts1, value: ...value.accounts1 }
]}
This will give you the same object in label and value. Or if you need specific values just:
items={[
{ label: value.accounts1.label, value: value.accounts1.value}
]}
For example. But it depends on what shape of the data you're expecting.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.