I am working on a testapp in react-native and try to get Images from a local storage place. Actual what I am doing: I give an image directlink source to a var and call this method at my render function.
*react: ^0.14.8 ||**react-native: ^0.23.1||**npm: 2.15.1 ||**node: v4.4.4*
Working:
ImageCall-File (Imagefile.js)
var samplepicture;setPicture(){ samplepicture= require('./images/picture.png')}render() { this.setPicture; return(<Image source=samplepicture/> ); }
The code snippet above works in a created class which is named after (Imagefile.js)
The method above works pretty fine.
Now I'm where I want to get to > I want to save the image file in a separate js file which is styled like a JSON object.
Not working:
JS_JSON_File (pictureRef.js)
module.exports = {"pictureRef": {"picture": './images/picture.png'}}
ImageCall_File (Imagefile.js)
var pictureRef = require('./pictureRef.js');var samplepicture;setPicture(){ samplepicture= require(pictureRef.pictureRef.picture);}render() { this.setPicture; return(<Image source=samplepicture/> ); }
Debug the samplepicture:samplepicture = ./images/picture.png
Not sure if it is relevant but because it is a string it is formatted without the ''. Also keep in mind that I need to set the image source by the setPicture() function for my code.
*I debugged both versions of code and had the same output:
- Version 1: samplepicture = ./images/picture.png
- Version 2: samplepicture = ./images/picture.png
Please keep in mind that this is my first question and I really hoped to format everything right. Also I searched for many related issue´s and didn't find any solution
Thanks for your help.