From 4d24511bf8c59a566c9e049646639d27232f9b43 Mon Sep 17 00:00:00 2001 From: "marcusferl@web.de" Date: Wed, 29 Dec 2021 12:29:29 +0100 Subject: [PATCH] init --- App.js | 41 +++++++++++++++++++++++++++++++-------- App_plane.js | 44 ++++++++++++++++++++++++++++++++++++++++++ js/components/Quote.js | 12 ++++++++++++ package.json | 7 ++++--- 4 files changed, 93 insertions(+), 11 deletions(-) create mode 100644 App_plane.js create mode 100644 js/components/Quote.js diff --git a/App.js b/App.js index 09f879b..2cd8564 100644 --- a/App.js +++ b/App.js @@ -1,15 +1,40 @@ +import React, { Component } from 'react'; // Bei React bzw. Nativ immer importieren! import { StatusBar } from 'expo-status-bar'; -import { StyleSheet, Text, View } from 'react-native'; +import { Button, StyleSheet, Text, View } from 'react-native'; -export default function App() { - return ( - - Open up App.js to start working on your app! - - - ); +import Quote from './js/components/Quote'; + +const data = [ + { text: "Zitat1", author: "Author 1" }, + { text: "Zitat2", author: "Author 2" }, + { text: "Zitat3", author: "Author 3" }, + { text: "Zitat4", author: "Author 4" }, + { text: "Zitat5", author: "Author 5" }, +]; +export default class App extends Component { + state = { index: 0 }; //initialer Zustand + + // Darstellung der Komponente im UI + // Render wird automatisch ausgeführt + // a) Komponente erscheint im Ui (initialer Zustand) + // b) Zustand ändert sich (state) => this.setstate(...) + render() { + let index = this.state.index; + const quote = data[index]; + let nextIndex = index + 1; + if (nextIndex === data.length) nextIndex = 0; + return ( + //JSX + + +