@@ -34,10 +34,10 @@ npm install react-native-animated-loader --save
34
34
```
35
35
36
36
## Usage
37
-
37
+ ### Class Component
38
38
``` jsx
39
39
import React from ' react' ;
40
- import { StyleSheet } from ' react-native' ;
40
+ import { StyleSheet , Text } from ' react-native' ;
41
41
import AnimatedLoader from " react-native-animated-loader" ;
42
42
43
43
export default class Loader extends React .Component {
@@ -77,6 +77,41 @@ const styles = StyleSheet.create({
77
77
}
78
78
});
79
79
```
80
+ ### Functional Component
81
+
82
+ ``` jsx
83
+ import React , {useState , useEffect } from ' react' ;
84
+ import {StyleSheet , Text } from ' react-native' ;
85
+ import AnimatedLoader from ' react-native-animated-loader' ;
86
+ export default function App () {
87
+ const [visible , setVisible ] = useState (false );
88
+ useEffect (() => {
89
+ setInterval (() => {
90
+ setVisible (! visible);
91
+ }, 2000 );
92
+ }, []);
93
+
94
+ return (
95
+ < AnimatedLoader
96
+ visible= {visible}
97
+ overlayColor= " rgba(255,255,255,0.75)"
98
+ animationStyle= {styles .lottie }
99
+ speed= {1 }>
100
+ < Text > Doing something... < / Text >
101
+ < / AnimatedLoader>
102
+ );
103
+ }
104
+ const styles = StyleSheet .create ({
105
+ lottie: {
106
+ width: 100 ,
107
+ height: 100 ,
108
+ },
109
+ });
110
+
111
+ ```
112
+
113
+ ### Usage in Expo
114
+ [ Example for expo projects] ( https://snack.expo.dev/tTSGEcb5J )
80
115
81
116
### Loader files
82
117
@@ -95,7 +130,7 @@ You can find free lottie files for your loaders [here](https://lottiefiles.com/s
95
130
| ** ` loop ` ** | A boolean flag indicating whether or not the animation should loop. | ` true ` |
96
131
97
132
## Work in Progress
98
- - [ ] Add expo example
133
+ - [x ] Add expo example
99
134
- [ ] Add ability to render text with animations
100
135
- [ ] Add test cases
101
136
0 commit comments