You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/07/27 18:05:23 UTC

[GitHub] [apisix-website] guoqqqi commented on a change in pull request #430: fix: contributor card state

guoqqqi commented on a change in pull request #430:
URL: https://github.com/apache/apisix-website/pull/430#discussion_r677680993



##########
File path: website/src/pages/index.js
##########
@@ -259,20 +259,23 @@ const NewsletterSection = () => {
 };
 
 const Contributor200Poster = () => {
-  const [display, setDisplay] = useState(true);
+  const [display, setDisplay] = useState(false);
   const [theme, setTheme] = useState('light');
 
   useEffect(() => {
     addEventListener('click', () => {
-      if (localStorage.getItem('theme') !== theme) {
-        setTheme(localStorage.getItem('theme'));
-      };
+      setTheme(localStorage.getItem('theme'));
     });
-  }, [theme]);
-
-  if (!display || (typeof window !== 'undefined' && localStorage.getItem('SHOW_200_CONTRIBUTOR_EVENT_ENTRY'))) {
-    return null;
-  }
+    if (localStorage.getItem("theme")) {
+      setTheme(localStorage.getItem('theme'));
+    };
+    if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
+      setTheme('dark');
+    }
+    if (typeof window !== 'undefined' && !localStorage.getItem('SHOW_200_CONTRIBUTOR_EVENT_ENTRY')) {

Review comment:
       ```suggestion
       if (!localStorage.getItem('SHOW_200_CONTRIBUTOR_EVENT_ENTRY')) {
   ```
   In the `useEffect` Hook we can no longer conditionally determine the existence of a window object

##########
File path: website/src/pages/index.js
##########
@@ -259,20 +259,23 @@ const NewsletterSection = () => {
 };
 
 const Contributor200Poster = () => {
-  const [display, setDisplay] = useState(true);
+  const [display, setDisplay] = useState(false);
   const [theme, setTheme] = useState('light');
 
   useEffect(() => {
     addEventListener('click', () => {
-      if (localStorage.getItem('theme') !== theme) {
-        setTheme(localStorage.getItem('theme'));
-      };
+      setTheme(localStorage.getItem('theme'));
     });
-  }, [theme]);
-
-  if (!display || (typeof window !== 'undefined' && localStorage.getItem('SHOW_200_CONTRIBUTOR_EVENT_ENTRY'))) {
-    return null;
-  }
+    if (localStorage.getItem("theme")) {
+      setTheme(localStorage.getItem('theme'));
+    };
+    if (window.matchMedia('(prefers-color-scheme: dark)').matches) {

Review comment:
       Hi, is there more to the description here? I'm not quite sure why we need to listen to themes in this way




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org