How to add images? (React Native)












0















I tried several codes but I only have errors every time.
How to add images from my gallery (no links) one below the other, with text
at the top and bottom of each image?



Like this:


example






import React, { Component } from "react";
import { Text, View, StyleSheet, Image, ImageBackground,ScrollView } from "react-native";
import withBackground from "../components/WithBackground";

class LinksScreen extends Component {
render() {
return (

<ScrollView>
<text>Hi</text>
<Image source={require('./assets/images/ici.jpg')} />
<text> Hello</text>

<text> Hi2</text>
<Image source={require('./assets/images/ici2.jpg')} />
<text> Hello2</text>
</ScrollView>

);
}}

export default withBackground(LinksScreen);





I am novice,
any help would be appreciated.










share|improve this question




















  • 1





    Can you show the errors you are getting?

    – Jose Vf
    Nov 22 '18 at 13:13











  • I don't have a code error but the screen of my android is red. (error code: 500) followed by a long text.

    – Lylys
    Nov 22 '18 at 13:24











  • Possible duplicate of Where to put images in a react-native project?

    – kivul
    Nov 22 '18 at 13:42











  • @Lylys Well, can you post a screenshot of the error instead?

    – Jose Vf
    Nov 22 '18 at 16:04
















0















I tried several codes but I only have errors every time.
How to add images from my gallery (no links) one below the other, with text
at the top and bottom of each image?



Like this:


example






import React, { Component } from "react";
import { Text, View, StyleSheet, Image, ImageBackground,ScrollView } from "react-native";
import withBackground from "../components/WithBackground";

class LinksScreen extends Component {
render() {
return (

<ScrollView>
<text>Hi</text>
<Image source={require('./assets/images/ici.jpg')} />
<text> Hello</text>

<text> Hi2</text>
<Image source={require('./assets/images/ici2.jpg')} />
<text> Hello2</text>
</ScrollView>

);
}}

export default withBackground(LinksScreen);





I am novice,
any help would be appreciated.










share|improve this question




















  • 1





    Can you show the errors you are getting?

    – Jose Vf
    Nov 22 '18 at 13:13











  • I don't have a code error but the screen of my android is red. (error code: 500) followed by a long text.

    – Lylys
    Nov 22 '18 at 13:24











  • Possible duplicate of Where to put images in a react-native project?

    – kivul
    Nov 22 '18 at 13:42











  • @Lylys Well, can you post a screenshot of the error instead?

    – Jose Vf
    Nov 22 '18 at 16:04














0












0








0








I tried several codes but I only have errors every time.
How to add images from my gallery (no links) one below the other, with text
at the top and bottom of each image?



Like this:


example






import React, { Component } from "react";
import { Text, View, StyleSheet, Image, ImageBackground,ScrollView } from "react-native";
import withBackground from "../components/WithBackground";

class LinksScreen extends Component {
render() {
return (

<ScrollView>
<text>Hi</text>
<Image source={require('./assets/images/ici.jpg')} />
<text> Hello</text>

<text> Hi2</text>
<Image source={require('./assets/images/ici2.jpg')} />
<text> Hello2</text>
</ScrollView>

);
}}

export default withBackground(LinksScreen);





I am novice,
any help would be appreciated.










share|improve this question
















I tried several codes but I only have errors every time.
How to add images from my gallery (no links) one below the other, with text
at the top and bottom of each image?



Like this:


example






import React, { Component } from "react";
import { Text, View, StyleSheet, Image, ImageBackground,ScrollView } from "react-native";
import withBackground from "../components/WithBackground";

class LinksScreen extends Component {
render() {
return (

<ScrollView>
<text>Hi</text>
<Image source={require('./assets/images/ici.jpg')} />
<text> Hello</text>

<text> Hi2</text>
<Image source={require('./assets/images/ici2.jpg')} />
<text> Hello2</text>
</ScrollView>

);
}}

export default withBackground(LinksScreen);





I am novice,
any help would be appreciated.






import React, { Component } from "react";
import { Text, View, StyleSheet, Image, ImageBackground,ScrollView } from "react-native";
import withBackground from "../components/WithBackground";

class LinksScreen extends Component {
render() {
return (

<ScrollView>
<text>Hi</text>
<Image source={require('./assets/images/ici.jpg')} />
<text> Hello</text>

<text> Hi2</text>
<Image source={require('./assets/images/ici2.jpg')} />
<text> Hello2</text>
</ScrollView>

);
}}

export default withBackground(LinksScreen);





import React, { Component } from "react";
import { Text, View, StyleSheet, Image, ImageBackground,ScrollView } from "react-native";
import withBackground from "../components/WithBackground";

class LinksScreen extends Component {
render() {
return (

<ScrollView>
<text>Hi</text>
<Image source={require('./assets/images/ici.jpg')} />
<text> Hello</text>

<text> Hi2</text>
<Image source={require('./assets/images/ici2.jpg')} />
<text> Hello2</text>
</ScrollView>

);
}}

export default withBackground(LinksScreen);






javascript image react-native text






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 19:33









Jose Vf

737620




737620










asked Nov 22 '18 at 13:11









LylysLylys

227




227








  • 1





    Can you show the errors you are getting?

    – Jose Vf
    Nov 22 '18 at 13:13











  • I don't have a code error but the screen of my android is red. (error code: 500) followed by a long text.

    – Lylys
    Nov 22 '18 at 13:24











  • Possible duplicate of Where to put images in a react-native project?

    – kivul
    Nov 22 '18 at 13:42











  • @Lylys Well, can you post a screenshot of the error instead?

    – Jose Vf
    Nov 22 '18 at 16:04














  • 1





    Can you show the errors you are getting?

    – Jose Vf
    Nov 22 '18 at 13:13











  • I don't have a code error but the screen of my android is red. (error code: 500) followed by a long text.

    – Lylys
    Nov 22 '18 at 13:24











  • Possible duplicate of Where to put images in a react-native project?

    – kivul
    Nov 22 '18 at 13:42











  • @Lylys Well, can you post a screenshot of the error instead?

    – Jose Vf
    Nov 22 '18 at 16:04








1




1





Can you show the errors you are getting?

– Jose Vf
Nov 22 '18 at 13:13





Can you show the errors you are getting?

– Jose Vf
Nov 22 '18 at 13:13













I don't have a code error but the screen of my android is red. (error code: 500) followed by a long text.

– Lylys
Nov 22 '18 at 13:24





I don't have a code error but the screen of my android is red. (error code: 500) followed by a long text.

– Lylys
Nov 22 '18 at 13:24













Possible duplicate of Where to put images in a react-native project?

– kivul
Nov 22 '18 at 13:42





Possible duplicate of Where to put images in a react-native project?

– kivul
Nov 22 '18 at 13:42













@Lylys Well, can you post a screenshot of the error instead?

– Jose Vf
Nov 22 '18 at 16:04





@Lylys Well, can you post a screenshot of the error instead?

– Jose Vf
Nov 22 '18 at 16:04












3 Answers
3






active

oldest

votes


















1














Can you give a screenshot of the result you are expecting?
There is something called a FlatList you can use that to achieve a list of images.



Note : menuData is an array of objects and Item is an object that has image title and URL



<FlatList
data={this.props.menuData}
renderItem={({ item }) => {
return(
<View style={{ flexDirection: 'row' }}>
<Image source={require(item.imageURL)} />
<Text>{item.imageText}</Text>
</View>
);
}}
keyExtractor={(item) => item.title }
/>


Use this style for Text:



textStyle: {
flex: 1,
width: '100%',
position: 'absolute',
alignSelf: 'center',
backgroundColor: 'rgba(0.57, 0.57, 0.57, 0.3)',
height: '100%',
}





share|improve this answer


























  • see my post please, I updated it

    – Lylys
    Nov 22 '18 at 13:49











  • Happy to help, and welcome to Stack Overflow. If this answer or any other one solved your issue, please mark it as accepted.

    – Manju Basha
    Nov 23 '18 at 5:10











  • @Lylys i saw you error screenshot. It is related to the export default code that you have written. You can export only one component by default in a module. So kindly change your code to export withBackGround(LinksScreen); instead of export default withBackGround(LinksScreen);

    – Manju Basha
    Nov 23 '18 at 5:18











  • yes I understand, but doing this 'export withBackGround (LinksScreen);' the word "export" is underlined in red. An idea to keep my background and add images? (This background code allows me to use a single code for the background of all my pages)

    – Lylys
    Nov 23 '18 at 9:37











  • You are importing withBackground in LinksScreen Component. You are again trying to export it in the same component. So literally you are exporting it twice. Both in LinksScreen and in WithBackground.js. You are not allowed to do that is the error. So what are you trying to achieve? retain same image for all or retain the layout and load images>

    – Manju Basha
    Nov 23 '18 at 12:22



















0














I am going to show you a possibility of working with native-base, but it's just a suggestion. You can see some possibilities in the official docs: https://docs.nativebase.io/Components.html#Components



import React, { Component } from 'react';
import { Image, ImageBackground, View } from 'react-native';
import { Card, CardItem, Text, Left, Right } from 'native-base';
import styles from './styles';

class ProductImage extends Component {
render() {
return (
<View style={{ flex: 1 }}>
<ImageBackground
style={ styles.image }
source={{ uri: this.props.photo }}
>
</ImageBackground>
</View>
);
}
}

export default ProductImage


So if you want to put a photo without props, it's just put the link image, like 'https://www.w3schools.com/w3css/img_lights.jpg'. Don't forget to install the dependence: npm install native-base --save






share|improve this answer
























  • I already have a background image => "export default with Background (LinksScreen);" I only want to put an image a bit like a map with text below and above.

    – Lylys
    Nov 22 '18 at 13:42



















0














Can you try this once:



<ScrollView> 
<View>
<Text>Hi</Text>
<Image source={require('./assets/snack-icon.png')} style={{ width: '100%',
height: 150, marginBottom: 10, padding: 10 }} resizeMode="cover" />
</View>
<View>
<Text> Hi2</Text>
<Image source={require('./assets/snack-icon.png')} style={{ width: '100%',
height: 150, marginBottom: 10, padding: 10 }} resizeMode="cover" />
<Text> Hello2</Text>
</View>
</ScrollView>





share|improve this answer
























  • As you explained above,Text between the images. I haven't added at the top of image. Do you need to add the text at top of image?

    – Suprabha
    Nov 22 '18 at 13:53











  • yes but, it doesn't work the screen of my android device is still red.

    – Lylys
    Nov 22 '18 at 13:55













  • What's the error you are getting ?

    – Suprabha
    Nov 22 '18 at 13:56











  • I was checking here, You can check this: snack.expo.io/@supi/YW54aW If still you are getting any error, then just let me know. Will check from my end

    – Suprabha
    Nov 22 '18 at 14:04













  • this is the result : image.noelshack.com/fichiers/2018/47/4/…

    – Lylys
    Nov 22 '18 at 14:27











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53431795%2fhow-to-add-images-react-native%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Can you give a screenshot of the result you are expecting?
There is something called a FlatList you can use that to achieve a list of images.



Note : menuData is an array of objects and Item is an object that has image title and URL



<FlatList
data={this.props.menuData}
renderItem={({ item }) => {
return(
<View style={{ flexDirection: 'row' }}>
<Image source={require(item.imageURL)} />
<Text>{item.imageText}</Text>
</View>
);
}}
keyExtractor={(item) => item.title }
/>


Use this style for Text:



textStyle: {
flex: 1,
width: '100%',
position: 'absolute',
alignSelf: 'center',
backgroundColor: 'rgba(0.57, 0.57, 0.57, 0.3)',
height: '100%',
}





share|improve this answer


























  • see my post please, I updated it

    – Lylys
    Nov 22 '18 at 13:49











  • Happy to help, and welcome to Stack Overflow. If this answer or any other one solved your issue, please mark it as accepted.

    – Manju Basha
    Nov 23 '18 at 5:10











  • @Lylys i saw you error screenshot. It is related to the export default code that you have written. You can export only one component by default in a module. So kindly change your code to export withBackGround(LinksScreen); instead of export default withBackGround(LinksScreen);

    – Manju Basha
    Nov 23 '18 at 5:18











  • yes I understand, but doing this 'export withBackGround (LinksScreen);' the word "export" is underlined in red. An idea to keep my background and add images? (This background code allows me to use a single code for the background of all my pages)

    – Lylys
    Nov 23 '18 at 9:37











  • You are importing withBackground in LinksScreen Component. You are again trying to export it in the same component. So literally you are exporting it twice. Both in LinksScreen and in WithBackground.js. You are not allowed to do that is the error. So what are you trying to achieve? retain same image for all or retain the layout and load images>

    – Manju Basha
    Nov 23 '18 at 12:22
















1














Can you give a screenshot of the result you are expecting?
There is something called a FlatList you can use that to achieve a list of images.



Note : menuData is an array of objects and Item is an object that has image title and URL



<FlatList
data={this.props.menuData}
renderItem={({ item }) => {
return(
<View style={{ flexDirection: 'row' }}>
<Image source={require(item.imageURL)} />
<Text>{item.imageText}</Text>
</View>
);
}}
keyExtractor={(item) => item.title }
/>


Use this style for Text:



textStyle: {
flex: 1,
width: '100%',
position: 'absolute',
alignSelf: 'center',
backgroundColor: 'rgba(0.57, 0.57, 0.57, 0.3)',
height: '100%',
}





share|improve this answer


























  • see my post please, I updated it

    – Lylys
    Nov 22 '18 at 13:49











  • Happy to help, and welcome to Stack Overflow. If this answer or any other one solved your issue, please mark it as accepted.

    – Manju Basha
    Nov 23 '18 at 5:10











  • @Lylys i saw you error screenshot. It is related to the export default code that you have written. You can export only one component by default in a module. So kindly change your code to export withBackGround(LinksScreen); instead of export default withBackGround(LinksScreen);

    – Manju Basha
    Nov 23 '18 at 5:18











  • yes I understand, but doing this 'export withBackGround (LinksScreen);' the word "export" is underlined in red. An idea to keep my background and add images? (This background code allows me to use a single code for the background of all my pages)

    – Lylys
    Nov 23 '18 at 9:37











  • You are importing withBackground in LinksScreen Component. You are again trying to export it in the same component. So literally you are exporting it twice. Both in LinksScreen and in WithBackground.js. You are not allowed to do that is the error. So what are you trying to achieve? retain same image for all or retain the layout and load images>

    – Manju Basha
    Nov 23 '18 at 12:22














1












1








1







Can you give a screenshot of the result you are expecting?
There is something called a FlatList you can use that to achieve a list of images.



Note : menuData is an array of objects and Item is an object that has image title and URL



<FlatList
data={this.props.menuData}
renderItem={({ item }) => {
return(
<View style={{ flexDirection: 'row' }}>
<Image source={require(item.imageURL)} />
<Text>{item.imageText}</Text>
</View>
);
}}
keyExtractor={(item) => item.title }
/>


Use this style for Text:



textStyle: {
flex: 1,
width: '100%',
position: 'absolute',
alignSelf: 'center',
backgroundColor: 'rgba(0.57, 0.57, 0.57, 0.3)',
height: '100%',
}





share|improve this answer















Can you give a screenshot of the result you are expecting?
There is something called a FlatList you can use that to achieve a list of images.



Note : menuData is an array of objects and Item is an object that has image title and URL



<FlatList
data={this.props.menuData}
renderItem={({ item }) => {
return(
<View style={{ flexDirection: 'row' }}>
<Image source={require(item.imageURL)} />
<Text>{item.imageText}</Text>
</View>
);
}}
keyExtractor={(item) => item.title }
/>


Use this style for Text:



textStyle: {
flex: 1,
width: '100%',
position: 'absolute',
alignSelf: 'center',
backgroundColor: 'rgba(0.57, 0.57, 0.57, 0.3)',
height: '100%',
}






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 22 '18 at 14:00

























answered Nov 22 '18 at 13:36









Manju BashaManju Basha

312420




312420













  • see my post please, I updated it

    – Lylys
    Nov 22 '18 at 13:49











  • Happy to help, and welcome to Stack Overflow. If this answer or any other one solved your issue, please mark it as accepted.

    – Manju Basha
    Nov 23 '18 at 5:10











  • @Lylys i saw you error screenshot. It is related to the export default code that you have written. You can export only one component by default in a module. So kindly change your code to export withBackGround(LinksScreen); instead of export default withBackGround(LinksScreen);

    – Manju Basha
    Nov 23 '18 at 5:18











  • yes I understand, but doing this 'export withBackGround (LinksScreen);' the word "export" is underlined in red. An idea to keep my background and add images? (This background code allows me to use a single code for the background of all my pages)

    – Lylys
    Nov 23 '18 at 9:37











  • You are importing withBackground in LinksScreen Component. You are again trying to export it in the same component. So literally you are exporting it twice. Both in LinksScreen and in WithBackground.js. You are not allowed to do that is the error. So what are you trying to achieve? retain same image for all or retain the layout and load images>

    – Manju Basha
    Nov 23 '18 at 12:22



















  • see my post please, I updated it

    – Lylys
    Nov 22 '18 at 13:49











  • Happy to help, and welcome to Stack Overflow. If this answer or any other one solved your issue, please mark it as accepted.

    – Manju Basha
    Nov 23 '18 at 5:10











  • @Lylys i saw you error screenshot. It is related to the export default code that you have written. You can export only one component by default in a module. So kindly change your code to export withBackGround(LinksScreen); instead of export default withBackGround(LinksScreen);

    – Manju Basha
    Nov 23 '18 at 5:18











  • yes I understand, but doing this 'export withBackGround (LinksScreen);' the word "export" is underlined in red. An idea to keep my background and add images? (This background code allows me to use a single code for the background of all my pages)

    – Lylys
    Nov 23 '18 at 9:37











  • You are importing withBackground in LinksScreen Component. You are again trying to export it in the same component. So literally you are exporting it twice. Both in LinksScreen and in WithBackground.js. You are not allowed to do that is the error. So what are you trying to achieve? retain same image for all or retain the layout and load images>

    – Manju Basha
    Nov 23 '18 at 12:22

















see my post please, I updated it

– Lylys
Nov 22 '18 at 13:49





see my post please, I updated it

– Lylys
Nov 22 '18 at 13:49













Happy to help, and welcome to Stack Overflow. If this answer or any other one solved your issue, please mark it as accepted.

– Manju Basha
Nov 23 '18 at 5:10





Happy to help, and welcome to Stack Overflow. If this answer or any other one solved your issue, please mark it as accepted.

– Manju Basha
Nov 23 '18 at 5:10













@Lylys i saw you error screenshot. It is related to the export default code that you have written. You can export only one component by default in a module. So kindly change your code to export withBackGround(LinksScreen); instead of export default withBackGround(LinksScreen);

– Manju Basha
Nov 23 '18 at 5:18





@Lylys i saw you error screenshot. It is related to the export default code that you have written. You can export only one component by default in a module. So kindly change your code to export withBackGround(LinksScreen); instead of export default withBackGround(LinksScreen);

– Manju Basha
Nov 23 '18 at 5:18













yes I understand, but doing this 'export withBackGround (LinksScreen);' the word "export" is underlined in red. An idea to keep my background and add images? (This background code allows me to use a single code for the background of all my pages)

– Lylys
Nov 23 '18 at 9:37





yes I understand, but doing this 'export withBackGround (LinksScreen);' the word "export" is underlined in red. An idea to keep my background and add images? (This background code allows me to use a single code for the background of all my pages)

– Lylys
Nov 23 '18 at 9:37













You are importing withBackground in LinksScreen Component. You are again trying to export it in the same component. So literally you are exporting it twice. Both in LinksScreen and in WithBackground.js. You are not allowed to do that is the error. So what are you trying to achieve? retain same image for all or retain the layout and load images>

– Manju Basha
Nov 23 '18 at 12:22





You are importing withBackground in LinksScreen Component. You are again trying to export it in the same component. So literally you are exporting it twice. Both in LinksScreen and in WithBackground.js. You are not allowed to do that is the error. So what are you trying to achieve? retain same image for all or retain the layout and load images>

– Manju Basha
Nov 23 '18 at 12:22













0














I am going to show you a possibility of working with native-base, but it's just a suggestion. You can see some possibilities in the official docs: https://docs.nativebase.io/Components.html#Components



import React, { Component } from 'react';
import { Image, ImageBackground, View } from 'react-native';
import { Card, CardItem, Text, Left, Right } from 'native-base';
import styles from './styles';

class ProductImage extends Component {
render() {
return (
<View style={{ flex: 1 }}>
<ImageBackground
style={ styles.image }
source={{ uri: this.props.photo }}
>
</ImageBackground>
</View>
);
}
}

export default ProductImage


So if you want to put a photo without props, it's just put the link image, like 'https://www.w3schools.com/w3css/img_lights.jpg'. Don't forget to install the dependence: npm install native-base --save






share|improve this answer
























  • I already have a background image => "export default with Background (LinksScreen);" I only want to put an image a bit like a map with text below and above.

    – Lylys
    Nov 22 '18 at 13:42
















0














I am going to show you a possibility of working with native-base, but it's just a suggestion. You can see some possibilities in the official docs: https://docs.nativebase.io/Components.html#Components



import React, { Component } from 'react';
import { Image, ImageBackground, View } from 'react-native';
import { Card, CardItem, Text, Left, Right } from 'native-base';
import styles from './styles';

class ProductImage extends Component {
render() {
return (
<View style={{ flex: 1 }}>
<ImageBackground
style={ styles.image }
source={{ uri: this.props.photo }}
>
</ImageBackground>
</View>
);
}
}

export default ProductImage


So if you want to put a photo without props, it's just put the link image, like 'https://www.w3schools.com/w3css/img_lights.jpg'. Don't forget to install the dependence: npm install native-base --save






share|improve this answer
























  • I already have a background image => "export default with Background (LinksScreen);" I only want to put an image a bit like a map with text below and above.

    – Lylys
    Nov 22 '18 at 13:42














0












0








0







I am going to show you a possibility of working with native-base, but it's just a suggestion. You can see some possibilities in the official docs: https://docs.nativebase.io/Components.html#Components



import React, { Component } from 'react';
import { Image, ImageBackground, View } from 'react-native';
import { Card, CardItem, Text, Left, Right } from 'native-base';
import styles from './styles';

class ProductImage extends Component {
render() {
return (
<View style={{ flex: 1 }}>
<ImageBackground
style={ styles.image }
source={{ uri: this.props.photo }}
>
</ImageBackground>
</View>
);
}
}

export default ProductImage


So if you want to put a photo without props, it's just put the link image, like 'https://www.w3schools.com/w3css/img_lights.jpg'. Don't forget to install the dependence: npm install native-base --save






share|improve this answer













I am going to show you a possibility of working with native-base, but it's just a suggestion. You can see some possibilities in the official docs: https://docs.nativebase.io/Components.html#Components



import React, { Component } from 'react';
import { Image, ImageBackground, View } from 'react-native';
import { Card, CardItem, Text, Left, Right } from 'native-base';
import styles from './styles';

class ProductImage extends Component {
render() {
return (
<View style={{ flex: 1 }}>
<ImageBackground
style={ styles.image }
source={{ uri: this.props.photo }}
>
</ImageBackground>
</View>
);
}
}

export default ProductImage


So if you want to put a photo without props, it's just put the link image, like 'https://www.w3schools.com/w3css/img_lights.jpg'. Don't forget to install the dependence: npm install native-base --save







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 '18 at 13:34









yoongi_syoongi_s

74




74













  • I already have a background image => "export default with Background (LinksScreen);" I only want to put an image a bit like a map with text below and above.

    – Lylys
    Nov 22 '18 at 13:42



















  • I already have a background image => "export default with Background (LinksScreen);" I only want to put an image a bit like a map with text below and above.

    – Lylys
    Nov 22 '18 at 13:42

















I already have a background image => "export default with Background (LinksScreen);" I only want to put an image a bit like a map with text below and above.

– Lylys
Nov 22 '18 at 13:42





I already have a background image => "export default with Background (LinksScreen);" I only want to put an image a bit like a map with text below and above.

– Lylys
Nov 22 '18 at 13:42











0














Can you try this once:



<ScrollView> 
<View>
<Text>Hi</Text>
<Image source={require('./assets/snack-icon.png')} style={{ width: '100%',
height: 150, marginBottom: 10, padding: 10 }} resizeMode="cover" />
</View>
<View>
<Text> Hi2</Text>
<Image source={require('./assets/snack-icon.png')} style={{ width: '100%',
height: 150, marginBottom: 10, padding: 10 }} resizeMode="cover" />
<Text> Hello2</Text>
</View>
</ScrollView>





share|improve this answer
























  • As you explained above,Text between the images. I haven't added at the top of image. Do you need to add the text at top of image?

    – Suprabha
    Nov 22 '18 at 13:53











  • yes but, it doesn't work the screen of my android device is still red.

    – Lylys
    Nov 22 '18 at 13:55













  • What's the error you are getting ?

    – Suprabha
    Nov 22 '18 at 13:56











  • I was checking here, You can check this: snack.expo.io/@supi/YW54aW If still you are getting any error, then just let me know. Will check from my end

    – Suprabha
    Nov 22 '18 at 14:04













  • this is the result : image.noelshack.com/fichiers/2018/47/4/…

    – Lylys
    Nov 22 '18 at 14:27
















0














Can you try this once:



<ScrollView> 
<View>
<Text>Hi</Text>
<Image source={require('./assets/snack-icon.png')} style={{ width: '100%',
height: 150, marginBottom: 10, padding: 10 }} resizeMode="cover" />
</View>
<View>
<Text> Hi2</Text>
<Image source={require('./assets/snack-icon.png')} style={{ width: '100%',
height: 150, marginBottom: 10, padding: 10 }} resizeMode="cover" />
<Text> Hello2</Text>
</View>
</ScrollView>





share|improve this answer
























  • As you explained above,Text between the images. I haven't added at the top of image. Do you need to add the text at top of image?

    – Suprabha
    Nov 22 '18 at 13:53











  • yes but, it doesn't work the screen of my android device is still red.

    – Lylys
    Nov 22 '18 at 13:55













  • What's the error you are getting ?

    – Suprabha
    Nov 22 '18 at 13:56











  • I was checking here, You can check this: snack.expo.io/@supi/YW54aW If still you are getting any error, then just let me know. Will check from my end

    – Suprabha
    Nov 22 '18 at 14:04













  • this is the result : image.noelshack.com/fichiers/2018/47/4/…

    – Lylys
    Nov 22 '18 at 14:27














0












0








0







Can you try this once:



<ScrollView> 
<View>
<Text>Hi</Text>
<Image source={require('./assets/snack-icon.png')} style={{ width: '100%',
height: 150, marginBottom: 10, padding: 10 }} resizeMode="cover" />
</View>
<View>
<Text> Hi2</Text>
<Image source={require('./assets/snack-icon.png')} style={{ width: '100%',
height: 150, marginBottom: 10, padding: 10 }} resizeMode="cover" />
<Text> Hello2</Text>
</View>
</ScrollView>





share|improve this answer













Can you try this once:



<ScrollView> 
<View>
<Text>Hi</Text>
<Image source={require('./assets/snack-icon.png')} style={{ width: '100%',
height: 150, marginBottom: 10, padding: 10 }} resizeMode="cover" />
</View>
<View>
<Text> Hi2</Text>
<Image source={require('./assets/snack-icon.png')} style={{ width: '100%',
height: 150, marginBottom: 10, padding: 10 }} resizeMode="cover" />
<Text> Hello2</Text>
</View>
</ScrollView>






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 '18 at 13:52









SuprabhaSuprabha

1556




1556













  • As you explained above,Text between the images. I haven't added at the top of image. Do you need to add the text at top of image?

    – Suprabha
    Nov 22 '18 at 13:53











  • yes but, it doesn't work the screen of my android device is still red.

    – Lylys
    Nov 22 '18 at 13:55













  • What's the error you are getting ?

    – Suprabha
    Nov 22 '18 at 13:56











  • I was checking here, You can check this: snack.expo.io/@supi/YW54aW If still you are getting any error, then just let me know. Will check from my end

    – Suprabha
    Nov 22 '18 at 14:04













  • this is the result : image.noelshack.com/fichiers/2018/47/4/…

    – Lylys
    Nov 22 '18 at 14:27



















  • As you explained above,Text between the images. I haven't added at the top of image. Do you need to add the text at top of image?

    – Suprabha
    Nov 22 '18 at 13:53











  • yes but, it doesn't work the screen of my android device is still red.

    – Lylys
    Nov 22 '18 at 13:55













  • What's the error you are getting ?

    – Suprabha
    Nov 22 '18 at 13:56











  • I was checking here, You can check this: snack.expo.io/@supi/YW54aW If still you are getting any error, then just let me know. Will check from my end

    – Suprabha
    Nov 22 '18 at 14:04













  • this is the result : image.noelshack.com/fichiers/2018/47/4/…

    – Lylys
    Nov 22 '18 at 14:27

















As you explained above,Text between the images. I haven't added at the top of image. Do you need to add the text at top of image?

– Suprabha
Nov 22 '18 at 13:53





As you explained above,Text between the images. I haven't added at the top of image. Do you need to add the text at top of image?

– Suprabha
Nov 22 '18 at 13:53













yes but, it doesn't work the screen of my android device is still red.

– Lylys
Nov 22 '18 at 13:55







yes but, it doesn't work the screen of my android device is still red.

– Lylys
Nov 22 '18 at 13:55















What's the error you are getting ?

– Suprabha
Nov 22 '18 at 13:56





What's the error you are getting ?

– Suprabha
Nov 22 '18 at 13:56













I was checking here, You can check this: snack.expo.io/@supi/YW54aW If still you are getting any error, then just let me know. Will check from my end

– Suprabha
Nov 22 '18 at 14:04







I was checking here, You can check this: snack.expo.io/@supi/YW54aW If still you are getting any error, then just let me know. Will check from my end

– Suprabha
Nov 22 '18 at 14:04















this is the result : image.noelshack.com/fichiers/2018/47/4/…

– Lylys
Nov 22 '18 at 14:27





this is the result : image.noelshack.com/fichiers/2018/47/4/…

– Lylys
Nov 22 '18 at 14:27


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53431795%2fhow-to-add-images-react-native%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

Npm cannot find a required file even through it is in the searched directory