TwicPics / components

A Web component library that brings the power of TwicPics to your favorite web framework.
MIT License
53 stars 2 forks source link

TwicImg for React throws null ref error #86

Closed motiazu closed 6 months ago

motiazu commented 6 months ago

Getting the following error using TwicImg in different layouts and screens in my app.

?v1&step=200:1 Uncaught TypeError: Cannot read properties of null (reading 'appendChild')
    at Be (?v1&step=200:1:3311)
    at ?v1&step=200:1:4719
    at Object.Y (?v1&step=200:1:2103)
    at ?v1&step=200:1:4878
    at ?v1&step=200:1:13591
    at ?v1&step=200:1:4883
    at Array.forEach (<anonymous>)
    at ?v1&step=200:1:153
    at ?v1&step=200:1:13553
    at NodeList.forEach (<anonymous>)
    at ?v1&step=200:1:153
    at ?v1&step=200:1:13758
    at Array.forEach (<anonymous>)
    at ?v1&step=200:1:153
    at S.X (?v1&step=200:1:13699)

Using @twicpics/components version 0.26.0, in a nextjs app dir project. The error happens also in components that are purely client components. It seems to reproduce on renders where an image was removed/added, doesn't happen on renders that don't change the images.

I found it hard to set up a working sandbox with the error just because of and all, if there is some readymade sandbox you have I can try and reproduce in there.

mbgspcii commented 6 months ago

Hi @motiazu

I must confess that we've never tested this kind of use case.

If you can try to reproduce the case on this stackblitz (you'll probably have to clone the stackblitz and send me the link to this new project), hat would be a big help.

motiazu commented 6 months ago

After some tinkering I see that it seems to only happen in dev, and for images with eager set to true. Reproduced here

mbgspcii commented 6 months ago

Hi @motiazu

Version 0.27.1 should fix the issue.

Thank you for reporting.

motiazu commented 5 months ago

Looks like it's working :) Thanks!