Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import React from "react";
  2. import {
  3. StyleSheet,
  4. View,
  5. ScrollView,
  6. Button,
  7. Text,
  8. AsyncStorage
  9. } from "react-native";
  10.  
  11. export default class Home extends React.Component {
  12. static navigationOptions = {
  13. title: "Название приложения"
  14. };
  15.  
  16. constructor(props) {
  17. super(props);
  18. this.state = {
  19. date: "",
  20. noteList: []
  21. };
  22. }
  23.  
  24. displayNoteList = () => {
  25. return this.state.noteList.map(note => {
  26. return (
  27. <View>
  28. <Text>{note.id}</Text>
  29. </View>
  30. )
  31. })
  32. }
  33.  
  34. componentDidMount() {
  35.  
  36. AsyncStorage.getItem('noteList', (error, result) => {
  37. if (!error) {
  38. if (result !== null) {
  39. this.setState({ noteList: result })
  40. }
  41. }
  42. })
  43. }
  44.  
  45. render() {
  46. return (
  47. <View>
  48. { this.displayNoteList() }
  49. </View>
  50. );
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement