feat(admin,admin-ui,medusa): Add Medusa Admin plugin (#3334)
This commit is contained in:
committed by
GitHub
parent
d6b1ad1ccd
commit
40de54b010
@@ -0,0 +1,23 @@
|
||||
import * as React from "react"
|
||||
import { toast, ToastOptions } from "react-hot-toast"
|
||||
|
||||
export type ToasterProps = {
|
||||
visible: boolean
|
||||
children: React.ReactElement
|
||||
} & ToastOptions
|
||||
|
||||
const Toaster = ({ visible, children, ...options }: ToasterProps) => {
|
||||
React.useEffect(() => {
|
||||
if (visible) {
|
||||
toast.custom((t) => React.cloneElement(children, { toast: t }), {
|
||||
...options,
|
||||
})
|
||||
} else {
|
||||
toast.dismiss(options.id)
|
||||
}
|
||||
}, [visible, children])
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export default Toaster
|
||||
Reference in New Issue
Block a user