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>(
3939 useEffect ( ( ) => {
4040 index . current ++
4141 push && addToast ( push )
42- console . log ( toasts )
43- console . log ( index . current )
4442 } , [ push ] )
4543
4644 // TODO: remove invisible items
4745 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+ ] )
5253 }
5354
5455 // a.splice(a.findIndex(e => e.name === "tc_001"),1);
@@ -68,23 +69,17 @@ export const CToaster = forwardRef<HTMLDivElement, CToasterProps>(
6869 )
6970
7071 const toaster = ( ref ?: React . Ref < HTMLDivElement > ) => {
71- return ( toasts . length > 0 || children ? (
72+ return toasts . length > 0 || children ? (
7273 < div className = { _className } { ...rest } ref = { ref } >
7374 { children }
74- {
75- toasts . map ( ( toast ) => toast )
76- }
75+ { toasts . map ( ( toast ) => toast ) }
7776 </ div >
78- ) : null )
77+ ) : null
7978 }
8079
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 )
8883 } ,
8984)
9085
You can’t perform that action at this time.
0 commit comments