//Local import (relative path)
<Image source={require("./assets/snack-icon.png")} />
//External import (web path) you should specify the width and height
<Image source={{uri:"https://picsum.photos/200", width:200,height:200 }}/>
import React from "react";
import { StyleSheet, View, Image} from "react-native";
const Test = () => {
return (
<View>
<Image source={require('./images/orangutan.jpg')} style={{width: 300, height: 300}} />
</View>
);
};
const styles = StyleSheet.create({
container: {
height: 200, width: 200
},
});
export default Test;
<Image style={{height: 200, width: 200}}
source={require('./images/orangutan.jpg')}
/>
<Image
style={styles.tinyLogo}
source={require('@expo/snack-static/react-native-logo.png')}
/>
// useing require is more secure
<Image
source = {require('C:/Users/Tutorialspoint/Desktop/NativeReactSample/logo.png')}
/>
<Image //change imagePath with the real path of your image, for example ./src/image/image.jpg
source={require("imagePath")}
/>
const staticImage = require("./assets/favicon.png");
export default function App() {
return (
<Image
style={styles.tinyLogo}
source={staticImage}
/>
);
}
yarn add react-native-image-viewing