title: TypeError: undefined is not an object (evaluating style.width) react native
body: <p>I just wanted to add an <code>&lt;ImageBackground&gt;</code> to my React Native project, but I always get the error message: "TypeError: undefined is not an object (evaluating style.width)". Error located at ImageBackground (at index.js:31).</p>
  
  <p>I have another project where it works perfectly like this. Could it be a problem of the React Native version?</p>
  
  <pre><code>import React, {Component} from 'react'
  import {
  StyleSheet,
  View,
  TouchableOpacity,
  Text,
  AsyncStorage,
  Dimensions,
  ImageBackground
  } from 'react-native'
  import * as Colors from '../../themes/colors'
  import {getNavigationOptions} from '../../utils/navigation'
  import * as ducks from '../../ducks'
  import {connect} from 'react-redux'
  
  class LoginScreen extends Component{
    login(){
      const {updateCurrentUser} = this.props
      updateCurrentUser({name: 'Mauricio'})
      console.log('login', this.props.currentUser)
    }
  
  olvidarContraseña(){
     console.log('olvidar contraseña')
  }
  
  render(){
  return (
    &lt;View style={styles.container}&gt;
      &lt;View style={[styles.input, {borderColor: Colors.primary}]}&gt;
        &lt;ImageBackground&gt;
          style={styles.backgroundImage}
          source={require('./trigo_background.jpg')}&gt;
          {/* &lt;TouchableOpacity
            style={styles.btnSubmit}
            onPress={() =&gt; this.login()}
          &gt;
            &lt;Text style={{textAlign: 'center', color: Colors.primary}}&gt;
              Iniciar Sesión
            &lt;/Text&gt;
          &lt;/TouchableOpacity&gt; */}
        &lt;/ImageBackground&gt;
      &lt;/View&gt;
    &lt;/View&gt;
  )
  }
  }
  
  const styles = StyleSheet.create({
   container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF'
  },
  backgroundImage: {
   width: Dimensions.get('window').width,
   height: Dimensions.get('window').height,
   position: 'absolute',
   top: 0,
   left: 0
  },
  btnSubmit: {
   justifyContent: 'center',
   padding: 10,
   flexDirection: 'row'
  },
  input: {
   height: 40,
   paddingHorizontal: 10,
   borderWidth: 1,
   borderRadius: 5
   }
  })
  
  LoginScreen.navigationOptions = ({navigation}) =&gt;
    getNavigationOptions('Login', Colors.primary, 'white')
  
  const mapStateToProps = store =&gt; ({
     currentUser: store.currentUser
  })
  
  const mapDispatchToProps = {
    updateCurrentUser: ducks.updateCurrentUser
  }
  
  export default connect(mapStateToProps, mapDispatchToProps)(LoginScreen)
  </code></pre>