I ran into a silly issue I don't know how to solve.
I have a screen with a camera that takes a photo and returns a path to the previous screen. In this screen, I want to display the photo that was taken. I have a path to the photo.
So the standard way to display an image is <Image style={styles.img} source={require('../path/img.png')} />
This is what I try to do:
</View> {this.state.photoFile ? ( <Image style={styles.img} source={require(this.state.photoFile)} /> ) : null} </View> I get an error Invalid call at line #
I tried to get around it with
this.state = { photoFile: '../../resources/logo.png' } ... <Image style={styles.img} source={require(this.state.photoFile)} /> let img = require('../../resources/logo.png') if (this.state.photoFile) { img = require(this.state.photoFile) } and even
let path = '../../resources/logo.png' if (this.state.photoFile) path = this.state.photoFile let img = require(path) But none worked.
How do I get around this? Thanks.