next-optimized-images icon indicating copy to clipboard operation
next-optimized-images copied to clipboard

Import image as ReactComponent

Open Darksoulsong opened this issue 5 years ago • 1 comments

Currently, I'm trying to use next-optimized-images with @svgr/webpack, but I noticed they don't play along nicely. With the latter I can import SVG images as react components and I'm wondering if this is feasible with NOI, so I can stop using one in favor of the other.

Is this possible?

Darksoulsong avatar Jul 28 '20 16:07 Darksoulsong

The upcoming major version (v3, currently in the canary branch) provides an Svg component which I think is exactly what you want. However, it uses a span tag as a wrapper currently but I plan to use svgr internally within this Svg component which would resolve that issue. The change to svgr should be in one of the next canary versions.

I can't say how long it will take until v3 is published on a non-canary tag, but if you want, you can already start using it using the @canary version. It should already be stable, just a few planned features need to be done.

cyrilwanner avatar Jul 29 '20 18:07 cyrilwanner