-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.tsx
More file actions
41 lines (35 loc) · 962 Bytes
/
Copy pathindex.tsx
File metadata and controls
41 lines (35 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React from 'react';
import {Wrapper, Container, ProgressBar} from '@fast-base/native';
const ProgressExample: React.FC = () => {
const countInterval = React.useRef(null);
const [count, setCount] = React.useState(0);
React.useEffect(() => {
if (count >= 100) {
clearInterval(countInterval.current);
}
}, [count]);
React.useEffect(() => {
countInterval.current = setInterval(() => {
setCount(current => {
const random = Math.random() * 10;
return current + random > 100 ? 100 : current + random;
});
}, 1000);
return () => {
clearInterval(countInterval.current);
};
}, []);
return (
<Container p={10}>
<Wrapper flex ay="center" ax="center">
<ProgressBar
width={300}
value={count}
useNativeDriver={false}
progressColor="green-500"
/>
</Wrapper>
</Container>
);
};
export default ProgressExample;