Loading local static images in elm-native-ui is not obvious. So I have figured out how to do that and suggesting a small API change. The React Native doc about Image loading is here.
Here is a simple description what this modification makes possible.
All images are referenced by relative to elm.js, so the directory structure become like follows.
Loading local static images in
elm-native-ui
is not obvious. So I have figured out how to do that and suggesting a small API change. The React Native doc about Image loading is here.Here is a simple description what this modification makes possible.
All images are referenced by relative to
elm.js
, so the directory structure become like follows.We need a small Native module to require the image files then return them as an object. The content of
src/Native/Images.js
isIn an Elm code, you can load this image like this.
If you want to load an image from remote like before, change the property name to
sourceUri
.