Просмотр исходного кода

fix(ui): Add empty dependency array to useLegacyStore (#29086)

Adds empty dependency array to prevent continual calls to listen and unlisten
David Wang 3 лет назад
Родитель
Сommit
a8929cb5a4
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      static/app/stores/useLegacyStore.tsx

+ 1 - 1
static/app/stores/useLegacyStore.tsx

@@ -19,7 +19,7 @@ export function useLegacyStore<T extends LegacyStoreShape>(
   const [state, setState] = useState(store.get());
   // Not all stores emit the new state, call get on change
   const callback = () => setState(store.get());
-  useEffect(() => store.listen(callback, undefined) as () => void);
+  useEffect(() => store.listen(callback, undefined) as () => void, []);
 
   return state;
 }