1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-10-16 15:07:27 +00:00
festa/components/postcard/Postcard.tsx
2022-06-04 05:13:19 +02:00

28 lines
669 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(typeof src === "object") {
setPostcard(src.src)
}
else {
setPostcard(src)
}
}
},
[src]
)
return null
}