也许这是一个幼稚的问题,但我不明白这个语法,为什么不在这里返回一个组件?
// src/@core/styles/libs/react-hot-toast
const ReactHotToast = styled(Box)<BoxProps>(({ theme }) => {
// ** Hook & Var
const { settings } = useSettings()
const { layout, navHidden } = settings
return {
'& > div': {
left: `${theme.spacing(6)} !important`,
right: `${theme.spacing(6)} !important`,
bottom: `${theme.spacing(6)} !important`,
top:
layout === 'horizontal' && !navHidden
? '139px !important'
: '75px !important',
},
'& .react-hot-toast': {
fontWeight: 400,
borderRadius: 8,
fontSize: '1rem',
letterSpacing: '0.14px',
boxShadow: theme.shadows[3],
zIndex: theme.zIndex.snackbar,
color: theme.palette.text.primary,
background: theme.palette.background.paper,
'&>:first-of-type:not([role])>:first-of-type': {
width: 14,
height: 14,
},
},
}
})
在_app.tsx
分钟内,它在这里装载,并通过
// ** Styled Components
import ReactHotToast from 'src/@core/styles/libs/react-hot-toast'
//..
<ReactHotToast>
<Toaster
position={settings.toastPosition}
toastOptions={{ className: 'react-hot-toast' }}
/>
</ReactHotToast>