Skip to content

Commit

Permalink
🐞 fix([BUG] Mapping key has multiple children #128: Solution: Refacto…
Browse files Browse the repository at this point in the history
…r use-snack.tsx to import React and update AnimatePresence usage):
  • Loading branch information
ballyalley-o committed Apr 15, 2024
1 parent 9c9af30 commit c9864dc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/hook/use-snack/use-snack.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Fragment } from 'react'
import React, { Fragment } from 'react'
import { m, AnimatePresence } from 'framer-motion'
import { SnackbarProvider as NotistackProvider, useSnackbar } from 'notistack'
import { Slide, IconButton } from '@mui/material'
import { useIcon, ICON_NAME } from 'hook'
import { ICON_WEB_NAME } from 'config'
import { KEY, COLOR as COLOR_CONSTANT } from 'constant'
import { SSnackContent, SSnackIconMDiv } from './style'
import { Iconify } from 'component/iconify'

interface SnackProviderProps {
children: React.ReactNode
Expand Down Expand Up @@ -47,7 +46,11 @@ export default function SnackProvider({ children }: SnackProviderProps) {
<Icon icon={closeSrc} />
</IconButton>
)}>
<AnimatePresence>{children}</AnimatePresence>
<AnimatePresence>
{React.Children.map(children, (child, index) => (
<m.div key={index}>{child}</m.div>
))}
</AnimatePresence>
</NotistackProvider>
</Fragment>
)
Expand Down

0 comments on commit c9864dc

Please sign in to comment.