aboutsummaryrefslogtreecommitdiffstats
path: root/components/Loader.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'components/Loader.jsx')
-rw-r--r--components/Loader.jsx20
1 files changed, 20 insertions, 0 deletions
diff --git a/components/Loader.jsx b/components/Loader.jsx
new file mode 100644
index 0000000..1804502
--- /dev/null
+++ b/components/Loader.jsx
@@ -0,0 +1,20 @@
+import { Text } from 'react-native'
+import { useState, useEffect } from "react"
+
+const Loader = ({ style = {}, text = 'Loading...' }) => {
+ const [nr, setNr] = useState(0)
+
+ useEffect(() => {
+ const timer = setTimeout(() => {
+ nr < text.length
+ ? setNr(nr+1)
+ : clearTimeout(timer)
+ }, 50);
+
+ return () => clearTimeout(timer);
+ });
+
+ return <Text style={{ color: 'grey', ...style }}>{text.substring(0, nr)}</Text>
+}
+
+export default Loader