فهرست منبع

use useIsomorphicLayoutEffect

Yuki Takei 8 ماه پیش
والد
کامیت
ee83973d64
1فایلهای تغییر یافته به همراه4 افزوده شده و 4 حذف شده
  1. 4 4
      apps/app/src/states/auto-update/global.ts

+ 4 - 4
apps/app/src/states/auto-update/global.ts

@@ -1,4 +1,4 @@
-import { useEffect, useLayoutEffect } from 'react';
+import { useIsomorphicLayoutEffect } from 'usehooks-ts';
 
 
 import type { CommonProps } from '../../pages/utils/commons';
 import type { CommonProps } from '../../pages/utils/commons';
 import {
 import {
@@ -15,19 +15,19 @@ import {
 export const useAutoUpdateGlobalAtoms = (commonProps: CommonProps): void => {
 export const useAutoUpdateGlobalAtoms = (commonProps: CommonProps): void => {
   // Update pathname and user atoms
   // Update pathname and user atoms
   const [, setCurrentPathname] = useCurrentPathname();
   const [, setCurrentPathname] = useCurrentPathname();
-  useLayoutEffect(() => {
+  useIsomorphicLayoutEffect(() => {
     setCurrentPathname(commonProps.currentPathname);
     setCurrentPathname(commonProps.currentPathname);
   }, [setCurrentPathname, commonProps.currentPathname]);
   }, [setCurrentPathname, commonProps.currentPathname]);
 
 
   // Update user atom
   // Update user atom
   const [, setCurrentUser] = useCurrentUser();
   const [, setCurrentUser] = useCurrentUser();
-  useLayoutEffect(() => {
+  useIsomorphicLayoutEffect(() => {
     setCurrentUser(commonProps.currentUser);
     setCurrentUser(commonProps.currentUser);
   }, [setCurrentUser, commonProps.currentUser]);
   }, [setCurrentUser, commonProps.currentUser]);
 
 
   // Update CSRF token atom
   // Update CSRF token atom
   const [, setCsrfToken] = useCsrfToken();
   const [, setCsrfToken] = useCsrfToken();
-  useEffect(() => {
+  useIsomorphicLayoutEffect(() => {
     setCsrfToken(commonProps.csrfToken);
     setCsrfToken(commonProps.csrfToken);
   }, [setCsrfToken, commonProps.csrfToken]);
   }, [setCsrfToken, commonProps.csrfToken]);