mirror of
https://github.com/Steffo99/festa.git
synced 2024-12-23 07:04:22 +00:00
29 lines
669 B
TypeScript
29 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
|
||
|
}
|