Last active
March 29, 2022 07:25
-
-
Save thechaudharysab/5f65ecf7fc84b3d7e3fd45ee92d678a7 to your computer and use it in GitHub Desktop.
Loading component for React Native
This file contains 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 from 'react'; | |
import { View, ActivityIndicator, Text, StyleSheet } from 'react-native'; | |
function LoadingModal({ message }) { | |
return ( | |
<View style={styles.loading}> | |
<ActivityIndicator size='large' /> | |
<Text style={{ color: 'white', padding: 10 }}>{message}</Text> | |
</View> | |
); | |
} | |
const styles = StyleSheet.create({ | |
loading: { | |
position: 'absolute', | |
left: 0, | |
right: 0, | |
top: 0, | |
bottom: 0, | |
alignItems: 'center', | |
justifyContent: 'center', | |
backgroundColor: 'black', | |
opacity: 0.5, | |
zIndex: 3 | |
} | |
}) | |
export default LoadingModal; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use:
import LoadingModal from '../YOUR_PATH/LoadingModal';
useState
hook to show/hide the loaderconst [loading, setLoading] = useState(false);
{ loading && <LoadingModal message={'Please Wait...'} /> }
That's it!