React Native, can't contain children









up vote
1
down vote

favorite












I'm trying to put like a logo/picture in my app. I am already using BackgroundImage so I want to put Image on top of the background. Check my code below. Please help me figure it out.



import React from 'react';
import StyleSheet, Text, View, ImageBackground, Image from 'react-native';

export default class App extends React.Component
render()
return (
<ImageBackground source=require('./app/img/baky.jpeg') style=styles.container>
<View style=styles.inner>
<Image source=require('./app/img/logo.png') style=styles.logo> </Image>
<Text style=styles.txt> Hello!!!! </Text>
</View>
</ImageBackground>

);



const styles = StyleSheet.create(
container:
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
,
inner:
padding: '10%',
justifyContent: 'center',
flexDirection: 'row',
width: '100%',
height: '100%',
backgroundColor: 'rgba(255, 255, 255, .7)'
,
logo:
width: 50,
height: 50
,
txt:
color: 'black',


);









share|improve this question



















  • 3




    you have a space in-between the open and close tags. whitespace is an element (text node). make it self closing <Image />
    – rlemon
    Nov 9 at 20:56










  • @rhemon i just removed the space between the opening and closing tags and it worked! thanks!!!
    – Mar Mar
    Nov 9 at 21:23














up vote
1
down vote

favorite












I'm trying to put like a logo/picture in my app. I am already using BackgroundImage so I want to put Image on top of the background. Check my code below. Please help me figure it out.



import React from 'react';
import StyleSheet, Text, View, ImageBackground, Image from 'react-native';

export default class App extends React.Component
render()
return (
<ImageBackground source=require('./app/img/baky.jpeg') style=styles.container>
<View style=styles.inner>
<Image source=require('./app/img/logo.png') style=styles.logo> </Image>
<Text style=styles.txt> Hello!!!! </Text>
</View>
</ImageBackground>

);



const styles = StyleSheet.create(
container:
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
,
inner:
padding: '10%',
justifyContent: 'center',
flexDirection: 'row',
width: '100%',
height: '100%',
backgroundColor: 'rgba(255, 255, 255, .7)'
,
logo:
width: 50,
height: 50
,
txt:
color: 'black',


);









share|improve this question



















  • 3




    you have a space in-between the open and close tags. whitespace is an element (text node). make it self closing <Image />
    – rlemon
    Nov 9 at 20:56










  • @rhemon i just removed the space between the opening and closing tags and it worked! thanks!!!
    – Mar Mar
    Nov 9 at 21:23












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm trying to put like a logo/picture in my app. I am already using BackgroundImage so I want to put Image on top of the background. Check my code below. Please help me figure it out.



import React from 'react';
import StyleSheet, Text, View, ImageBackground, Image from 'react-native';

export default class App extends React.Component
render()
return (
<ImageBackground source=require('./app/img/baky.jpeg') style=styles.container>
<View style=styles.inner>
<Image source=require('./app/img/logo.png') style=styles.logo> </Image>
<Text style=styles.txt> Hello!!!! </Text>
</View>
</ImageBackground>

);



const styles = StyleSheet.create(
container:
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
,
inner:
padding: '10%',
justifyContent: 'center',
flexDirection: 'row',
width: '100%',
height: '100%',
backgroundColor: 'rgba(255, 255, 255, .7)'
,
logo:
width: 50,
height: 50
,
txt:
color: 'black',


);









share|improve this question















I'm trying to put like a logo/picture in my app. I am already using BackgroundImage so I want to put Image on top of the background. Check my code below. Please help me figure it out.



import React from 'react';
import StyleSheet, Text, View, ImageBackground, Image from 'react-native';

export default class App extends React.Component
render()
return (
<ImageBackground source=require('./app/img/baky.jpeg') style=styles.container>
<View style=styles.inner>
<Image source=require('./app/img/logo.png') style=styles.logo> </Image>
<Text style=styles.txt> Hello!!!! </Text>
</View>
</ImageBackground>

);



const styles = StyleSheet.create(
container:
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
,
inner:
padding: '10%',
justifyContent: 'center',
flexDirection: 'row',
width: '100%',
height: '100%',
backgroundColor: 'rgba(255, 255, 255, .7)'
,
logo:
width: 50,
height: 50
,
txt:
color: 'black',


);






javascript react-native






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 21:09









rlemon

13.5k1075114




13.5k1075114










asked Nov 9 at 20:45









Mar Mar

153




153







  • 3




    you have a space in-between the open and close tags. whitespace is an element (text node). make it self closing <Image />
    – rlemon
    Nov 9 at 20:56










  • @rhemon i just removed the space between the opening and closing tags and it worked! thanks!!!
    – Mar Mar
    Nov 9 at 21:23












  • 3




    you have a space in-between the open and close tags. whitespace is an element (text node). make it self closing <Image />
    – rlemon
    Nov 9 at 20:56










  • @rhemon i just removed the space between the opening and closing tags and it worked! thanks!!!
    – Mar Mar
    Nov 9 at 21:23







3




3




you have a space in-between the open and close tags. whitespace is an element (text node). make it self closing <Image />
– rlemon
Nov 9 at 20:56




you have a space in-between the open and close tags. whitespace is an element (text node). make it self closing <Image />
– rlemon
Nov 9 at 20:56












@rhemon i just removed the space between the opening and closing tags and it worked! thanks!!!
– Mar Mar
Nov 9 at 21:23




@rhemon i just removed the space between the opening and closing tags and it worked! thanks!!!
– Mar Mar
Nov 9 at 21:23












1 Answer
1






active

oldest

votes

















up vote
-2
down vote













Just change <Image source=require('./app/img/logo.png') style=styles.logo> </Image> to <Image source=require('./app/img/logo.png') style=styles.logo />






share|improve this answer




















    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',
    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%2f53233031%2freact-native-image-cant-contain-children%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    -2
    down vote













    Just change <Image source=require('./app/img/logo.png') style=styles.logo> </Image> to <Image source=require('./app/img/logo.png') style=styles.logo />






    share|improve this answer
























      up vote
      -2
      down vote













      Just change <Image source=require('./app/img/logo.png') style=styles.logo> </Image> to <Image source=require('./app/img/logo.png') style=styles.logo />






      share|improve this answer






















        up vote
        -2
        down vote










        up vote
        -2
        down vote









        Just change <Image source=require('./app/img/logo.png') style=styles.logo> </Image> to <Image source=require('./app/img/logo.png') style=styles.logo />






        share|improve this answer












        Just change <Image source=require('./app/img/logo.png') style=styles.logo> </Image> to <Image source=require('./app/img/logo.png') style=styles.logo />







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 9 at 20:56









        Andrew Allison

        310514




        310514



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233031%2freact-native-image-cant-contain-children%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

            Use pre created SQLite database for Android project in kotlin

            Darth Vader #20

            Ondo