8000 Suppress `useLayoutEffect` rehydration warning in `useDebugDashboard` by chrissantamaria · Pull Request #552 · yahoo/react-i13n · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Suppress useLayoutEffect rehydration warning in useDebugDashboard #552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/hooks/useDebugDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 5 additions & 0 deletions src/hooks/useIsomorphicLayoutEffect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { useLayoutEffect, useEffect } from 'react';

const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;

export default useIsomorphicLayoutEffect;
0