From 822657ba227e7c9bcad9af4597aaa2cffbdf657c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erhan=20G=C3=BCng=C3=B6r?= Date: Wed, 1 Sep 2021 18:55:27 +0300 Subject: [PATCH] prevent rendering twice on first load --- README.md | 4 ++-- example/index.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d854e96..d9b836e 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,8 @@ const Component = () => { const { switcher, themes, currentTheme, status } = useThemeSwitcher(); const [isDarkMode, setIsDarkMode] = React.useState(false); - if (status === 'loading') { - return
Loading styles...
; + if (status !== 'loaded') { + return null; } const toggleDarkMode = () => { diff --git a/example/index.tsx b/example/index.tsx index 47d942f..2256c15 100644 --- a/example/index.tsx +++ b/example/index.tsx @@ -9,8 +9,8 @@ const Component = () => { const { switcher, themes, currentTheme, status } = useThemeSwitcher(); const [isDarkMode, setIsDarkMode] = React.useState(true); - if (status === 'loading') { - return
Loading styles...
; + if (status !== 'loaded') { + return null; } const toggleDarkMode = checked => {