Skip to content

Commit

Permalink
feat: rendering a list
Browse files Browse the repository at this point in the history
  • Loading branch information
ap221882 committed Jan 9, 2023
1 parent 1a53503 commit 59c26e5
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 3 deletions.
4 changes: 3 additions & 1 deletion miscellaneous/react-native/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createAppContainer } from "react-navigation";
import { createStackNavigator } from "react-navigation-stack";
import HomeScreen from "./src/screens/HomeScreen";
import ComponentsScreen from "./src/screens/ComponentsScreen";
import ListScreen from "./src/screens/ListScreen";

/**
* * From react-navigation library used for routing
Expand All @@ -10,9 +11,10 @@ const navigator = createStackNavigator(
{
Home: HomeScreen,
Components: ComponentsScreen,
List: ListScreen,
},
{
initialRouteName: "Components",
initialRouteName: "List",
defaultNavigationOptions: {
title: "App",
},
Expand Down
122 changes: 122 additions & 0 deletions miscellaneous/react-native/assets/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
[
{
"id": 1,
"first_name": "Marge",
"email": "[email protected]",
"gender": "Female"
},
{
"id": 2,
"first_name": "Clevie",
"email": "[email protected]",
"gender": "Male"
},
{
"id": 3,
"first_name": "Seumas",
"email": "[email protected]",
"gender": "Male"
},
{
"id": 4,
"first_name": "Dyan",
"email": "[email protected]",
"gender": "Female"
},
{
"id": 5,
"first_name": "Grannie",
"email": "[email protected]",
"gender": "Male"
},
{
"id": 6,
"first_name": "Terese",
"email": "[email protected]",
"gender": "Female"
},
{
"id": 7,
"first_name": "Ludwig",
"email": "[email protected]",
"gender": "Male"
},
{
"id": 8,
"first_name": "Luther",
"email": "[email protected]",
"gender": "Male"
},
{
"id": 9,
"first_name": "Mitchael",
"email": "[email protected]",
"gender": "Male"
},
{
"id": 10,
"first_name": "Cherlyn",
"email": "[email protected]",
"gender": "Female"
},
{
"id": 11,
"first_name": "Ignacio",
"email": "[email protected]",
"gender": "Male"
},
{
"id": 12,
"first_name": "Stephen",
"email": "[email protected]",
"gender": "Male"
},
{
"id": 13,
"first_name": "Yves",
"email": "[email protected]",
"gender": "Male"
},
{
"id": 14,
"first_name": "Grady",
"email": "[email protected]",
"gender": "Male"
},
{
"id": 15,
"first_name": "Fanchon",
"email": "[email protected]",
"gender": "Female"
},
{
"id": 16,
"first_name": "Shermie",
"email": "[email protected]",
"gender": "Male"
},
{
"id": 17,
"first_name": "Aile",
"email": "[email protected]",
"gender": "Female"
},
{
"id": 18,
"first_name": "Melessa",
"email": "[email protected]",
"gender": "Female"
},
{
"id": 19,
"first_name": "Frank",
"email": "[email protected]",
"gender": "Male"
},
{
"id": 20,
"first_name": "Tallie",
"email": "[email protected]",
"gender": "Male"
}
]
25 changes: 23 additions & 2 deletions miscellaneous/react-native/src/screens/ListScreen.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
import { StyleSheet, Text, View } from "react-native";
import { StyleSheet, Text, View, FlatList } from "react-native";
import React from "react";

import studentData from "../../assets/data.json";

const ListScreen = () => {
return (
<View>
<Text>ListScreen</Text>
<FlatList
// horizontal // having horizontal scroll
// showsHorizontalScrollIndicator={false} // hiding horizontal scroll indicator
data={studentData}
keyExtractor={(item) => item.id}
renderItem={({ item }) => {
return (
<View style={styles.textStyle}>
<Text>Name: {item.first_name}</Text>
<Text>Gender:{item.gender}</Text>
<Text>Email: {item.email}</Text>
</View>
);
}}
/>
</View>
);
};

export default ListScreen;

const styles = StyleSheet.create({});
const styles = StyleSheet.create({
textStyle: {
marginVertical: 20,
},
});

2 comments on commit 59c26e5

@vercel
Copy link

@vercel vercel bot commented on 59c26e5 Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

namaste-react-parcel – ./Day3

namaste-react-parcel-git-main-ap221882.vercel.app
namaste-react-parcel.vercel.app
namaste-react-parcel-ap221882.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 59c26e5 Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

namaste-react – ./Day12/github-api-project-ts

namaste-react-ap221882.vercel.app
namaste-react.vercel.app
namaste-react-git-main-ap221882.vercel.app

Please sign in to comment.