I want to add data to the <Picker.Item> component of the JSON that I pulled from AsyncStorage. but the result is an error the following code that I made:
constructor(props) {
super(props);
this.state = {
url: '',
}
this.checkurl();
}
checkurl = async () => {
const urlget = await AsyncStorage.getItem('url');
if(urlget) {
this.setState({ url: urlget });
} else {
console.log('data url empty');
}
}
render () {
const urlListrender = this.state.url.map((item) =>
<Picker.Item label={item.alias} value={item.url} key={item.id}/>
);
return(
<View>
<Picker
style={styles.pickerText}
selectedValue={this.state.url}
onValueChange={(itemValue,itemIndex) => this.setState({url: itemValue})}>
{urlListrender}
</Picker>
</View>
)
}
what mistake have I made? how do i fix it?
try the following. I made changes to a few things.