I have an image uploader in my react-native app, once you upload the image it navigates you to another screen and previews the image there, in the image preview screen there is an input for giving a name for this image and a save button, when clicking on save button it should go back to the previous screen and display the image and it's name there inside the flatlist i have, i managed to do the steps until previewing the image but after that i didn't know what to do next, here is the code:
First screen:
state = {
image: null,
previews: []
};
_pickImage = async () => {
await Permissions.askAsync(Permissions.CAMERA_ROLL);
const {navigate} = await this.props.navigation;
let result = await ImagePicker.launchImageLibraryAsync({
allowsEditing: false,
aspect: [4, 4],
});
navigate( 'ImagePreview', { uri : result.uri } );
if (!result.cancelled) {
this.setState({ image: result.uri });
}
};
_keyExtractor (item, index) {
return index.toString();
}
_renderItem ({ item, index }) {
return (
<View>
<Image source={require('')}/>
<Text>Image title</Text>
</View>
);
}
<FlatList style={{ flex: 0.5 }}
data={this.state.previews}
keyExtractor={this._keyExtractor.bind(this)}
renderItem={this._renderItem.bind(this)}
numColumns={2}
/>
Second screen:
const uri = navigation.getParam('uri');
<Image source={{uri:uri}} style={{width: 200, height: 200}} />
<Button title="Save" />