1- import React , { useEffect , useRef , useState , useLayoutEffect } from 'react'
1+ import React , { useEffect , useRef , useState , useLayoutEffect , useMemo } from 'react'
22import PortalTooltip from '../PortalTooltip'
33import styles from './index.module.less'
44
55// SSR-safe useLayoutEffect
66const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect
77
8+ const EMPTY_STYLE = { }
9+ const EMPTY_TOOLTIP_PROPS = { }
10+
811/**
912 * OverflowText
1013 *
@@ -22,15 +25,18 @@ const OverflowText = ({
2225 minWidth = 0 ,
2326 maxWidth,
2427 className = '' ,
25- style = { } ,
26- tooltipProps = { } ,
28+ style = EMPTY_STYLE ,
29+ tooltipProps = EMPTY_TOOLTIP_PROPS ,
2730 alwaysShow = false ,
2831 lines = 0 ,
2932 onOverflowChange,
3033} ) => {
3134 const elRef = useRef ( null )
3235 const [ isOverflow , setIsOverflow ] = useState ( false )
3336
37+ // Stabilize style reference — only re-run effect when style content actually changes
38+ const stableStyleKey = useMemo ( ( ) => JSON . stringify ( style ) , [ style ] )
39+
3440 const check = ( ) => {
3541 const el = elRef . current
3642 if ( ! el ) return
@@ -60,7 +66,7 @@ const OverflowText = ({
6066 // Check on mount and updates
6167 useIsomorphicLayoutEffect ( ( ) => {
6268 check ( )
63- } , [ text , lines , maxWidth , style , className ] )
69+ } , [ text , lines , maxWidth , stableStyleKey , className ] )
6470
6571 useEffect ( ( ) => {
6672 const el = elRef . current
0 commit comments