In my Android react-native app I'm moving jpg files from cache folder to RNFS.DocumentDirectoryPath where I've created an "image" folder. I'm not able to render those images:
inside a react class:
state = {source:null}
async componentDidMount() {
async loadFile ( path ){
await this.setState({source:{uri:path}})
}
const path = RNFS.DocumentDirectoryPath+'/images/d88b102c-d4c6-4dc1-9a4c-f2a0e599ddbf.jpg'
await RNFS.exists(path).then( exists => {
if(exists){
this.loadFile(path);
}
}
renderItem = ({ item }) => (
<View key={item.Id} >
<View>
<TouchableOpacity onPress={() => this.onPressItem(item)}>
<Text>{item.cardName}</Text>
<Image
source={this.state.source}
style={{ width:'auto', height: 55 }}
/>
</TouchableOpacity>
</View>
</View>
);
The image exists if I convert it to base64 it get rendered correctly.
I was missing the "file://"
const path = "file://"+RNFS.DocumentDirectoryPath+'/images/d88b102c-d4c6-4dc1-9a4c-f2a0e599ddbf.jpg'