Advertisement
Felanpro

React Native ( map() )

May 20th, 2023
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import { StatusBar } from 'expo-status-bar';
  2. import { StyleSheet, Text, View, Image, SafeAreaView } from 'react-native';
  3. import React, { useState } from 'react';
  4.  
  5. const Lol = () => // Use map() to facilitate the process of returning multiple components at once
  6. {
  7. const numbers = [1, 2, 3, 4, 5];
  8. const listItems = numbers.map((x) => <Text style = {{backgroundColor: "green"}}>{x}</Text>);
  9.  
  10. return listItems;
  11. }
  12.  
  13. export default function App() {
  14.  
  15. return (
  16. <SafeAreaView style={styles.container}>
  17.  
  18. <Lol></Lol>
  19.  
  20. </SafeAreaView>
  21. );
  22. }
  23.  
  24. const styles = StyleSheet.create({
  25. container: {
  26. flex: 1,
  27. backgroundColor: '#fff',
  28. justifyContent: "center",
  29. alignItems: "center"
  30. },
  31. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement