Answer the question
In order to leave comments, you need to log in
How to output data from AsyncStorage + state (TypeError: undefined is not a function (near '..._this.state.noteList.map...'))?
Hello. The question is in the title. Source code here or below: https://pastebin.com/0JnA6D5b
import React from "react";
import {
StyleSheet,
View,
ScrollView,
Button,
Text,
AsyncStorage
} from "react-native";
export default class Home extends React.Component {
static navigationOptions = {
title: "Название приложения"
};
constructor(props) {
super(props);
this.state = {
date: "",
noteList: []
};
}
displayNoteList = () => {
return this.state.noteList.map(note => {
return (
<View>
<Text>{note.id}</Text>
</View>
)
})
}
componentDidMount() {
AsyncStorage.getItem('noteList', (error, result) => {
if (!error) {
if (result !== null) {
this.setState({ noteList: result })
}
}
})
}
render() {
return (
<View>
{ this.displayNoteList() }
</View>
);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question