-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
42 lines (38 loc) · 961 Bytes
/
Copy pathApp.tsx
File metadata and controls
42 lines (38 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React, {useState} from 'react';
import {Image, SafeAreaView, StyleSheet, Button, View} from 'react-native';
function App() {
const [showImage, setShowImage] = useState(false);
return (
<SafeAreaView style={styles.container}>
<View style={styles.buttonContainer}>
<Button
title={showImage ? 'Hide Image' : 'Show Image'}
onPress={() => setShowImage(!showImage)}
/>
</View>
{showImage && (
<Image
// resizeMethod="resize" // this solves the issue on Android
style={styles.image}
source={{
uri: 'https://roniccastro.s3.us-east-1.amazonaws.com/crash.jpg',
}}
onError={console.log}
/>
)}
</SafeAreaView>
);
}
const styles = StyleSheet.create({
image: {
width: '100%',
height: '100%',
},
container: {
flex: 1,
},
buttonContainer: {
marginBottom: 20,
},
});
export default App;