[英]Unexpected token, expected “,” in react-native expo
I am using RNPickerSelect and trying to put dynamic value to the dropdown list.我正在使用 RNPickerSelect 并尝试将动态值放入下拉列表。 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.在 RNPickerSelectm 项目值中,我试图从值中获取数据。
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.这将为您提供与 label 和值相同的 object 和值。 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.
但这取决于您期望的数据形状。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.