Created
October 24, 2019 18:04
-
-
Save mdshadman/9711d73d8757662e823e8e9047239ac5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import { View, Text, Button, FlatList, ActivityIndicator } from 'react-native'; | |
import styles from './ApiStyles'; | |
const ApiView = (props) => { | |
const { goForFetch, goForAxios, fromFetch, fromAxios, axiosData, renderItem, FlatListItemSeparator, dataSource, loading } = props | |
return ( | |
<View style={styles.parentContainer}> | |
<View style={{ margin: 18 }}> | |
<Button | |
title={'Click using Fetch'} | |
onPress={goForFetch} | |
color='green' | |
/> | |
</View> | |
<View style={{ margin: 18 }}> | |
<Button | |
title={'Click using axios'} | |
onPress={goForAxios} | |
color='green' | |
/> | |
</View> | |
{fromFetch ? | |
<FlatList | |
data={dataSource} | |
ItemSeparatorComponent={FlatListItemSeparator} | |
renderItem={item => renderItem(item)} | |
keyExtractor={item => item.id.toString()} | |
/> : <FlatList | |
data={axiosData} | |
ItemSeparatorComponent={FlatListItemSeparator} | |
renderItem={item => renderItem(item)} | |
keyExtractor={item => item.id.toString()} | |
/> | |
} | |
{loading && | |
<View style={styles.loader}> | |
<ActivityIndicator size="large" color="#0c9" /> | |
<Text>Fetching Data</Text> | |
</View> | |
} | |
</View> | |
) | |
} | |
export default ApiView; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment