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) {
|
2022-06-07 10:48:47 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2022-06-08 00:41:41 +00:00
|
|
|
[src, setPostcard]
|
2022-06-04 03:13:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
return null
|
|
|
|
}
|