Skip to content

Commit f6d0c09

Browse files
authored
refactor: port useIsomorphicEffect to typescript (#18888)
1 parent f5df03a commit f6d0c09

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

packages/react/src/internal/useIsomorphicEffect.js

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Copyright IBM Corp. 2021, 2025
3+
*
4+
* This source code is licensed under the Apache-2.0 license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import { useEffect, useLayoutEffect } from 'react';
9+
10+
/** `useLayoutEffect` on the client, `useEffect` on the server */
11+
const useIsomorphicEffect =
12+
typeof window !== 'undefined' ? useLayoutEffect : useEffect;
13+
14+
export default useIsomorphicEffect;

0 commit comments

Comments
 (0)