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

28 lines
680 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, setPostcard]
)
return null
}