cjohansen / portfolio

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem rendering app relying on `react-native-skia`

dmg46664 opened this issue · comments

Please see the following repo folder 0009_portfolio_skia_render for replication steps:

https://github.com/dmg46664/problems/blob/main/0009_portfolio_skia_render/README.md

This is replicating this kind of code: https://snack.expo.dev/@wcandillon/hello-snack
, where the main app needs to be loaded in separate module to ensure a web assembly binary has loaded first.

The error is in the second scene which appears blank, with the following in the console:

image

But note that this doesn't happen on the standalone instructions which draws a pretty picture.

I imagine that the issue is the way Portfolio is triggering the js which means document.geElementById is in the wrong window. This is just speculation given I am sufficiently unfamiliar with Portfolio.

Hi, sorry for the late response. Yes, Portfolio runs your component in one window, and renders the result in an iframe. This causes problems with globals such as document. I don't have a quickfix for this, but I do have one approach to attempt. As a work-around, you can do (.querySelector (.closest rendered-element "body") "#my-id") to work in the right document, but this is only possible if you control the code in question, and won't always work unfortunately.

This will soon have a solution by way of this PR: #16