mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-09-01 17:10:24 +08:00
Enables ref forwarding for improved integration with parent components and libraries that require direct DOM access. Enhances flexibility and maintainability by switching to a forwardRef implementation.
17 lines
513 B
TypeScript
17 lines
513 B
TypeScript
import NextImage, { type ImageProps } from "next/image"
|
|
import { forwardRef } from "react"
|
|
import { getAssetUrl } from "@/lib/base-path"
|
|
|
|
export default forwardRef<HTMLImageElement, ImageProps>(
|
|
function Image(props, ref) {
|
|
const src =
|
|
typeof props.src === "string" &&
|
|
props.src.startsWith("/") &&
|
|
!props.src.startsWith("//")
|
|
? getAssetUrl(props.src)
|
|
: props.src
|
|
|
|
return <NextImage {...props} src={src} ref={ref} />
|
|
},
|
|
)
|