I built images gallery by FlatList in my app, like this, it depends on a “react-native-img-cache” module.
In expo, I’m trying to build it like this:
...
async _loadAssetsAsync() {
let assets = [], i;
for (i = 0; i < this.props.data.length; i++) {
assets.push(this.props.data[i].key);
}
const imageAssets = cacheImages(assets);
await Promise.all([
...imageAssets
]);
this.setState({appIsReady: true});
}
......
<FlatList
contentContainerStyle={styles.container}
data = {this.props.data}
renderItem={({item}) =>
<TouchableOpacity>
<Image
source={{uri: item.key}}
style={styles.containerImage}
/>
</TouchableOpacity>
}
....
/>
It seems images have not been cached, what is the correct way to build this?
Thanks!