Failed to construct 'Image': Please use the 'new' operator
Answered
West African Crocodile posted this in #help-forum
West African CrocodileOP
Hi guys, i am trying to make sort of gallery where onClick() on Image creates new Image of same src, but with diferent class, position etc.
This is my code:
and this is error I am getting:
This is my code:
and this is error I am getting:
Answered by joulev
try
onClick={() => setZoomImage(false)} instead of onClick={setZoomImage(false)}29 Replies
@West African Crocodile Hi guys, i am trying to make sort of gallery where onClick() on Image creates new Image of same src, but with diferent class, position etc.
This is my code:
and this is error I am getting:
do you use
Image anywhere else? search for Image in your entire projectyou very likely used
Image somewhere without importing next/imageWest African CrocodileOP
i don't think so
these are my files
the files are fine. search for all the places in your project that you use
Imagewhat is the search result?
West African CrocodileOP
ok one moment sorry
am kinda new with all this 😅
these are results
this is componentImage.jsx file
weird... it's looks fine to me. can you send me the link to the repo?
its private
West African CrocodileOP
here try now, sorry haven't been in programming for while so am bit slow with stuff
@West African Crocodile https://github.com/KrNovak97/demo
try
onClick={() => setZoomImage(false)} instead of onClick={setZoomImage(false)}Answer
West African CrocodileOP
working!
thank you so much
â¤ï¸
you're welcome
@joulev try `onClick={() => setZoomImage(false)}` instead of `onClick={setZoomImage(false)}`
West African CrocodileOP
btw you have any idea why it didn't work the way i did?
@West African Crocodile btw you have any idea why it didn't work the way i did?
onClick has to be a function,
setZoomImage(false) is not a functionWest African CrocodileOP
i see
thank you