@@ -46,7 +46,7 @@ const NoticeList: FC<NoticeListProps> = (props) => {
4646 const { classNames : ctxCls } = useContext ( NotificationContext ) ;
4747
4848 const dictRef = useRef < Record < string , HTMLDivElement > > ( { } ) ;
49- const [ latestNotice , setLatestNotice ] = useState < HTMLDivElement > ( null ) ;
49+ const latestNoticeRef = useRef < HTMLDivElement > ( null ) ;
5050 const [ hoverKeys , setHoverKeys ] = useState < string [ ] > ( [ ] ) ;
5151
5252 const keys = configList . map ( ( config ) => ( {
@@ -72,7 +72,7 @@ const NoticeList: FC<NoticeListProps> = (props) => {
7272 // Force update latest notice
7373 useEffect ( ( ) => {
7474 if ( stack && dictRef . current [ keys [ keys . length - 1 ] ?. key ] ) {
75- setLatestNotice ( dictRef . current [ keys [ keys . length - 1 ] ?. key ] ) ;
75+ latestNoticeRef . current = dictRef . current [ keys [ keys . length - 1 ] ?. key ] ;
7676 }
7777 } , [ keys , stack ] ) ;
7878
@@ -115,7 +115,7 @@ const NoticeList: FC<NoticeListProps> = (props) => {
115115 if ( index > 0 ) {
116116 stackStyle . height = expanded
117117 ? dictRef . current [ strKey ] ?. offsetHeight
118- : latestNotice ?. offsetHeight ;
118+ : latestNoticeRef . current ?. offsetHeight ;
119119
120120 // Transform
121121 let verticalOffset = 0 ;
@@ -126,8 +126,8 @@ const NoticeList: FC<NoticeListProps> = (props) => {
126126 const transformY =
127127 ( expanded ? verticalOffset : index * offset ) * ( placement . startsWith ( 'top' ) ? 1 : - 1 ) ;
128128 const scaleX =
129- ! expanded && latestNotice ?. offsetWidth && dictRef . current [ strKey ] ?. offsetWidth
130- ? ( latestNotice ?. offsetWidth - offset * 2 * ( index < 3 ? index : 3 ) ) /
129+ ! expanded && latestNoticeRef . current ?. offsetWidth && dictRef . current [ strKey ] ?. offsetWidth
130+ ? ( latestNoticeRef . current ?. offsetWidth - offset * 2 * ( index < 3 ? index : 3 ) ) /
131131 dictRef . current [ strKey ] ?. offsetWidth
132132 : 1 ;
133133 stackStyle . transform = `translate3d(${ transformX } , ${ transformY } px, 0) scaleX(${ scaleX } )` ;
0 commit comments