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

29 lines
667 B
TypeScript
Raw Normal View History

2022-06-04 03:13:19 +00:00
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)
2022-06-04 03:13:19 +00:00
useEffect(
() => {
if(src) {
if(typeof src === "object") {
setPostcard(src.src)
}
else {
setPostcard(src)
}
}
},
[src]
)
return null
}