Skip to content

Commit 4ea8acf

Browse files
committed
chore: prevent webpack from analyzing useInsertionEffect
1 parent ae4e500 commit 4ea8acf

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/blade/src/utils/useCallbackRef.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
/* eslint-disable @typescript-eslint/explicit-function-return-type */
2-
import { useCallback, useInsertionEffect, useRef } from 'react';
3+
import React, { useCallback, useRef } from 'react';
34
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
45

5-
const useInsertionEffectFallback = useInsertionEffect || useIsomorphicLayoutEffect;
6+
// Prevent webpack from importing this:
7+
// https://github.com/webpack/webpack/issues/14814#issuecomment-1536757985
8+
// https://github.com/radix-ui/primitives/issues/2796
9+
const useReactInsertionEffect = (React as any)[' useInsertionEffect '.trim().toString()];
10+
const useInsertionEffectFallback = useReactInsertionEffect || useIsomorphicLayoutEffect;
611

712
/**
813
* This hook is user-land implementation of the experimental `useEffectEvent` hook.

0 commit comments

Comments
 (0)