Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
addToAlbum = async () => {
const { asset } = this.props.navigation.state.params!;
const expoAlbum = await MediaLibrary.getAlbumAsync(EXPO_ALBUM_NAME);
if (expoAlbum) {
await MediaLibrary.addAssetsToAlbumAsync(asset, expoAlbum);
} else {
await MediaLibrary.createAlbumAsync(EXPO_ALBUM_NAME, asset);
}
alert('Successfully added asset to Expo album!');
}