Open Zetxus opened 11 months ago
Getting the same issue.
Specifically, when initialContent contains dynamic elements within script tags. This will cause error "Cannot read properties of null (reading 'children')". Dynamic elements in non-script tags, such as divs, are fine.
I just encountered this, here's a small repo with reproduction:
https://github.com/Zetxus/react-frame-component-test
In our project this happens when we change the
initialCotnext
rapidly. In our case we're using the frame to render raw HTML instead of actual react components.I suspect some kind of a race condition, however I am not familiar enough with the internals of this project, so maybe someone could have an idea why this is happening? Here's the exact line in question https://github.com/ryanseddon/react-frame-component/blob/1b44f0a98a7b02710f7de6c6b0ed81cc524fc545/src/Frame.jsx#L74
Weirdly enough in the reproduction repo the error happens really soon when you touch the hue control but almost not at all when you rapidly change the color itself. No idea if this is just a coincidence. We're using a similar setup but with a different color picker. The result is the same.
A workaround that we currently use is to set the key property of the Frame itself to the html (basically the same as what we provide to the
initialContent
), which in turn forces a full re-render and somehow doesn't throw the exception. You can try this out by settingkey={color}
in the test repo.