@@ -46,7 +46,7 @@ const NoticeList: FC<NoticeListProps> = (props) => {
46
46
const { classNames : ctxCls } = useContext ( NotificationContext ) ;
47
47
48
48
const dictRef = useRef < Record < string , HTMLDivElement > > ( { } ) ;
49
- const latestNoticeRef = useRef < HTMLDivElement > ( null ) ;
49
+ const [ latestNotice , setLatestNotice ] = useState < HTMLDivElement > ( null ) ;
50
50
const [ hoverKeys , setHoverKeys ] = useState < string [ ] > ( [ ] ) ;
51
51
52
52
const keys = configList . map ( ( config ) => ( {
@@ -72,7 +72,7 @@ const NoticeList: FC<NoticeListProps> = (props) => {
72
72
// Force update latest notice
73
73
useEffect ( ( ) => {
74
74
if ( stack && dictRef . current [ keys [ keys . length - 1 ] ?. key ] ) {
75
- latestNoticeRef . current = dictRef . current [ keys [ keys . length - 1 ] ?. key ] ;
75
+ setLatestNotice ( dictRef . current [ keys [ keys . length - 1 ] ?. key ] ) ;
76
76
}
77
77
} , [ keys , stack ] ) ;
78
78
@@ -115,7 +115,7 @@ const NoticeList: FC<NoticeListProps> = (props) => {
115
115
if ( index > 0 ) {
116
116
stackStyle . height = expanded
117
117
? dictRef . current [ strKey ] ?. offsetHeight
118
- : latestNoticeRef . current ?. offsetHeight ;
118
+ : latestNotice ?. offsetHeight ;
119
119
120
120
// Transform
121
121
let verticalOffset = 0 ;
@@ -126,8 +126,8 @@ const NoticeList: FC<NoticeListProps> = (props) => {
126
126
const transformY =
127
127
( expanded ? verticalOffset : index * offset ) * ( placement . startsWith ( 'top' ) ? 1 : - 1 ) ;
128
128
const scaleX =
129
- ! expanded && latestNoticeRef . current ?. offsetWidth && dictRef . current [ strKey ] ?. offsetWidth
130
- ? ( latestNoticeRef . current ?. offsetWidth - offset * 2 * ( index < 3 ? index : 3 ) ) /
129
+ ! expanded && latestNotice ?. offsetWidth && dictRef . current [ strKey ] ?. offsetWidth
130
+ ? ( latestNotice ?. offsetWidth - offset * 2 * ( index < 3 ? index : 3 ) ) /
131
131
dictRef . current [ strKey ] ?. offsetWidth
132
132
: 1 ;
133
133
stackStyle . transform = `translate3d(${ transformX } , ${ transformY } px, 0) scaleX(${ scaleX } )` ;
0 commit comments