From 0abaa462194715c25cee5fcede0da3085939b402 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Tue, 16 May 2023 16:57:45 +0700
Subject: change image placeholder

---
 .../components/elements/DelayRender/DelayRender.jsx   | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 src/core/components/elements/DelayRender/DelayRender.jsx

(limited to 'src/core/components/elements/DelayRender/DelayRender.jsx')

diff --git a/src/core/components/elements/DelayRender/DelayRender.jsx b/src/core/components/elements/DelayRender/DelayRender.jsx
new file mode 100644
index 00000000..2d412be7
--- /dev/null
+++ b/src/core/components/elements/DelayRender/DelayRender.jsx
@@ -0,0 +1,19 @@
+const { useState, useEffect } = require('react')
+
+const DelayRender = ({ renderAfter = 200, children }) => {
+  const [renderComponent, setRenderComponent] = useState(false)
+
+  useEffect(() => {
+    const renderTimeout = setTimeout(() => {
+      setRenderComponent(true)
+    }, renderAfter)
+
+    return () => {
+      clearTimeout(renderTimeout)
+    }
+  }, [renderAfter])
+
+  return renderComponent && children
+}
+
+export default DelayRender
-- 
cgit v1.2.3

