Felhasználói eszközök

Eszközök a webhelyen


oktatas:telefon:react_native:todo

< React Native

Todo

Lista

App.js
import React from 'react';
import { StyleSheet, View } from 'react-native';
import { FlatList, Text } from "react-native";
import { useState } from 'react';
import Header from './components/header';
 
export default function App() {
  const [todos, setTodos] = useState([
    { task: 'Angular tanulás', id: '1' },
    { task: 'ReactNative tanulás', id: '2' },
    { task: 'Tisztkód tanulás', id: '3' },
    { task: 'JavaFX tanulás', id: '4' },
  ]);
 
  const renderItem = ({item}) => (    
    <View stlye={styles.item}>
      <Text style={styles.task}>{item.task}</Text>
    </View>
  );
 
  return (
    <View style={styles.container}>
      <Header />
        <FlatList 
          data={todos}
          renderItem={renderItem}
          keyExtractor={item => item.task}
        />
    </View>
  );
}
 
const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
  task: {    
    fontSize: 22,
  },
});
header.js
import React from "react";
import { StyleSheet, Text, View } from "react-native";
 
export default function Header() {
    return (
        <View style={styles.header}>
            <Text style={styles.title}>Fejrész</Text>
        </View>
    );
}
 
const styles = StyleSheet.create({
    header: {
        height: 80,
        width: '100%',
        backgroundColor: 'coral',
    },
    title: {
        fontSize: 32,
        textAlign: 'center',
        paddingTop: 10,
        fontWeight: 'bold',
        color: 'white',
    },
});
oktatas/telefon/react_native/todo.txt · Utolsó módosítás: 2021/09/01 16:40 szerkesztette: admin