File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 1+ import type { CSSMotionProps } from 'rc-motion' ;
12import * as React from 'react' ;
3+ import type { NotificationsRef , OpenConfig , Placement } from './Notifications' ;
24import Notifications from './Notifications' ;
3- import type { Placement } from './Notifications' ;
4- import type { NotificationsRef , OpenConfig } from './Notifications' ;
5- import type { CSSMotionProps } from 'rc-motion' ;
65
76const defaultGetContainer = ( ) => document . body ;
87
@@ -146,7 +145,12 @@ export default function useNotification(
146145 }
147146 } ) ;
148147
149- setTaskQueue ( [ ] ) ;
148+ // React 17 will mix order of effect & setState in async
149+ // - open: setState[0]
150+ // - effect[0]
151+ // - open: setState[1]
152+ // - effect setState([]) * here will clean up [0, 1] in React 17
153+ setTaskQueue ( ( oriQueue ) => oriQueue . filter ( ( task ) => ! taskQueue . includes ( task ) ) ) ;
150154 }
151155 } , [ taskQueue ] ) ;
152156
You can’t perform that action at this time.
0 commit comments