@@ -44,6 +44,11 @@ const createBaseToast = () => class ToastList extends BaseComponent<ToastListPro
4444 zIndex : 1010 ,
4545 content : '' ,
4646 } ;
47+
48+ /* REACT_19_START */
49+ // static toastQueue: Array<{ opts: ToastReactProps, id: string }> = [];
50+ /* REACT_19_END */
51+
4752 static propTypes = {
4853 content : PropTypes . node ,
4954 duration : PropTypes . number ,
@@ -146,19 +151,22 @@ const createBaseToast = () => class ToastList extends BaseComponent<ToastListPro
146151 // }
147152 // this.root.render(React.createElement(
148153 // ToastList,
149- // { ref: instance => (ToastList.ref = instance) }
154+ // { ref: instance => {
155+ // ToastList.ref = instance;
156+ // // New: flush toast queue after ref ready
157+ // while (ToastList.toastQueue.length && ToastList.ref && typeof ToastList.ref.add === 'function') {
158+ // const { opts: queuedOpts, id: queuedId } = ToastList.toastQueue.shift();
159+ // ToastList.ref.add({ ...queuedOpts, id: queuedId });
160+ // ToastList.ref.stack = Boolean(queuedOpts.stack);
161+ // }
162+ // } }
150163 // ));
151164 // // 在 React 19 中,render 是同步的,确保 ref 已赋值后再执行add方法
152- // if (typeof queueMicrotask === 'function') {
153- // queueMicrotask(() => {
154- // ToastList.ref.add({ ...opts, id });
155- // ToastList.ref.stack = Boolean(opts.stack);
156- // });
165+ // if (ToastList.ref && typeof ToastList.ref.add === 'function') {
166+ // ToastList.ref.add({ ...opts, id });
167+ // ToastList.ref.stack = Boolean(opts.stack);
157168 // } else {
158- // Promise.resolve().then(() => {
159- // ToastList.ref.add({ ...opts, id });
160- // ToastList.ref.stack = Boolean(opts.stack);
161- // });
169+ // ToastList.toastQueue.push({ opts, id });
162170 // }
163171 /* REACT_19_END */
164172 } else {
@@ -298,11 +306,11 @@ const createBaseToast = () => class ToastList extends BaseComponent<ToastListPro
298306 [ `${ cssClasses . PREFIX } -innerWrapper` ] : true ,
299307 [ `${ cssClasses . PREFIX } -innerWrapper-hover` ] : this . state . mouseInSide
300308 } ) } ref = { this . innerWrapperRef } onMouseEnter = { this . handleMouseEnter } onMouseLeave = { this . handleMouseLeave } >
301- { list . map ( ( item , index ) => {
302- const isRemoved = removedItems . find ( removedItem => removedItem . id === item . id ) !== undefined ;
303- return < CSSAnimation key = { item . id } motion = { item . motion } animationState = { isRemoved ? "leave" : "enter" } startClassName = { isRemoved ? `${ cssClasses . PREFIX } -animation-hide` : `${ cssClasses . PREFIX } -animation-show` } >
309+ { list . map ( ( item , index ) => {
310+ const isRemoved = removedItems . find ( removedItem => removedItem . id === item . id ) !== undefined ;
311+ return < CSSAnimation key = { item . id } motion = { item . motion } animationState = { isRemoved ? "leave" : "enter" } startClassName = { isRemoved ? `${ cssClasses . PREFIX } -animation-hide` : `${ cssClasses . PREFIX } -animation-show` } >
304312 {
305- ( { animationClassName, animationEventsNeedBind, isAnimating } ) => {
313+ ( { animationClassName, animationEventsNeedBind, isAnimating } ) => {
306314 return ( isRemoved && ! isAnimating ) ? null : < Toast { ...item } stack = { this . stack } stackExpanded = { this . state . mouseInSide } positionInList = { { length : list . length , index } } className = { cls ( {
307315 [ item . className ] : Boolean ( item . className ) ,
308316 [ animationClassName ] : true
0 commit comments