mjmeintjes/boot-react-native

requiring assets or node deps fails on reload

Closed this issue · 1 comments

When you require an image like so

(def arrow (js/require "../../imgs/arrow.png"))

it works on first load but fails when the code is reevaluated from boot-reload with a packager error (red screen of death). Similar problems have been reported with requiring regular react-native/node dependencies

(def animatable (js/require "react-native-animatable/index.js"))

A workaround is to use defonce.

Also worth mentioning that if you use Google Closure (cljs with advanced or possibly even simple compilation), you'll also need to set a javascript var, like so:

(aset js/global "Animatable" (js/require "react-native-animatable/index.js"))

In any case it would be great not to need the defonce workaround. Is this because of path issues, i.e. relative paths resolve to different directories in "first-run" and "reload" modes?

The defonce workaround works fine for me for the most part. If there's a better way to fix this, please re-open.