File tree Expand file tree Collapse file tree 1 file changed +13
-18
lines changed Expand file tree Collapse file tree 1 file changed +13
-18
lines changed Original file line number Diff line number Diff line change @@ -39,16 +39,17 @@ export const CToaster = forwardRef<HTMLDivElement, CToasterProps>(
39
39
useEffect ( ( ) => {
40
40
index . current ++
41
41
push && addToast ( push )
42
- console . log ( toasts )
43
- console . log ( index . current )
44
42
} , [ push ] )
45
43
46
44
// TODO: remove invisible items
47
45
const addToast = ( push : any ) => {
48
- setToasts ( ( state ) => [ ...state , React . cloneElement ( push , {
49
- key : index . current ,
50
- onDismiss : ( ) => setToasts ( ( state ) => state . filter ( ( i ) => i . key !== index . current ) ) ,
51
- } ) ] )
46
+ setToasts ( ( state ) => [
47
+ ...state ,
48
+ React . cloneElement ( push , {
49
+ key : index . current ,
50
+ onDismiss : ( ) => setToasts ( ( state ) => state . filter ( ( i ) => i . key !== index . current ) ) ,
51
+ } ) ,
52
+ ] )
52
53
}
53
54
54
55
// a.splice(a.findIndex(e => e.name === "tc_001"),1);
@@ -68,23 +69,17 @@ export const CToaster = forwardRef<HTMLDivElement, CToasterProps>(
68
69
)
69
70
70
71
const toaster = ( ref ?: React . Ref < HTMLDivElement > ) => {
71
- return ( toasts . length > 0 || children ? (
72
+ return toasts . length > 0 || children ? (
72
73
< div className = { _className } { ...rest } ref = { ref } >
73
74
{ children }
74
- {
75
- toasts . map ( ( toast ) => toast )
76
- }
75
+ { toasts . map ( ( toast ) => toast ) }
77
76
</ div >
78
- ) : null )
77
+ ) : null
79
78
}
80
79
81
- return (
82
- placement ? typeof window !== 'undefined' &&
83
- createPortal (
84
- toaster ( ref ) ,
85
- document . body ,
86
- ) : toaster ( ref )
87
- )
80
+ return placement
81
+ ? typeof window !== 'undefined' && createPortal ( toaster ( ref ) , document . body )
82
+ : toaster ( ref )
88
83
} ,
89
84
)
90
85
You can’t perform that action at this time.
0 commit comments