1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-12-23 07:04:22 +00:00
festa/components/postcard/Postcard.tsx

31 lines
772 B
TypeScript

import { useEffect } from "react"
import { PostcardContext } from "./PostcardContext"
import { useDefinedContext } from "../../utils/definedContext"
import { StaticImageData } from "next/image"
type PostcardProps = {
src?: string | StaticImageData
}
export function Postcard({ src }: PostcardProps) {
const { setPostcard } = useDefinedContext(PostcardContext)
useEffect(
() => {
if (src) {
if (src === undefined) {
return
}
if (typeof src === "object") {
setPostcard(src.src)
}
else {
setPostcard(src)
}
}
},
[src, setPostcard]
)
return null
}