5

I am using the ImageBackground component from React Native. However, no matter what style I choose the same error message always displays. The code looks as it follows:

  render() {
return (
  <ImageBackground
    source={require('./common/Background_image.png')}
    stlye={styles.backgroundStyle}
  >
    <Text>Some text here!!</Text>
  </ImageBackground>
);

}

  backgroundStyle: {
flex: 1,
width: null,
height: null,
resizeMode: 'cover'}

Image of the error here

React-Native version: react-native-cli: 2.0.1 react-native: 0.55.4

Any ideas of what this may happen?

2
  • why do you pass width: null, height: null,. Just delete it and try again. Commented Dec 9, 2018 at 18:48
  • Already tried that but I still obtain the same error Commented Dec 9, 2018 at 18:50

1 Answer 1

7

You are passing stlye but the correct syntax should be style

<ImageBackground
    source={require('./common/Background_image.png')}
    style={styles.backgroundStyle}
>
  <Text>Some text here!!</Text>
</ImageBackground>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot! I spent like 2 hours with this silly mistake!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.