diff --git a/src/hooks/useDebugDashboard.js b/src/hooks/useDebugDashboard.js index 5ef4275c..03e6f3f5 100644 --- a/src/hooks/useDebugDashboard.js +++ b/src/hooks/useDebugDashboard.js @@ -3,17 +3,18 @@ * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. */ -import { useLayoutEffect, useRef } from 'react'; +import { useRef } from 'react'; import { IS_DEBUG_MODE } from '../utils/variables'; import DebugDashboard from '../libs/DebugDashboard'; +import useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect'; const useDebugDashboard = ({ node }) => { const debugDashboard = useRef(); - useLayoutEffect(() => { + useIsomorphicLayoutEffect(() => { if (IS_DEBUG_MODE) { debugDashboard.current = new DebugDashboard(node); } diff --git a/src/hooks/useIsomorphicLayoutEffect.js b/src/hooks/useIsomorphicLayoutEffect.js new file mode 100644 index 00000000..633e7fea --- /dev/null +++ b/src/hooks/useIsomorphicLayoutEffect.js @@ -0,0 +1,5 @@ +import { useLayoutEffect, useEffect } from 'react'; + +const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect; + +export default useIsomorphicLayoutEffect;