cyrilwanner / next-optimized-images

🌅 next-optimized-images automatically optimizes images used in next.js projects (jpeg, png, svg, webp and gif).
MIT License
2.21k stars 93 forks source link

Error: Objects are not valid as a React child #268

Closed Treast closed 2 years ago

Treast commented 2 years ago

Hello ! Thanks for your project ! I try to go back to NextJS with the version 12 out, but got some issues with the plugin. Thanks for your help

Node version : 16.9.1 NextJS version: 12.0.1 next-optimized-images version : 3.0.0-canary.10

Steps to reproduce :

import bigImage from '../images/1500.jpeg';

export default function Home() { return (

Create Next App

); }



**Actual result :** 
`Error: Objects are not valid as a React child (found: object with keys {src, webpack}). If you meant to render a collection of children, use an array instead.`

**Expected result :** 
A page with the image displayed
Treast commented 2 years ago

Fixed.

If anybody got the same problem, the Image component has to be imported from react-optimized-images, and not from next-optimized-images.

import Img from 'react-optimized-image';