From 1173480fd93a56fa60333c01ffc70b67db82826a Mon Sep 17 00:00:00 2001
From: piotrruss <mail@pruss.it>
Date: Sun, 22 May 2022 18:11:30 +0100
Subject: added loader

---
 components/Loader.jsx | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 components/Loader.jsx

(limited to 'components/Loader.jsx')

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
-- 
cgit v1.2.3

