Search code examples
javascriptreactjsreact-nativereact-navigationreact-navigation-stack

Configuring defaultNavigationOption headerBackImage throws undefined


Configuring the defaultNavigationOptions as such:

defaultNavigationOptions: {
    headerStyle: {},
    headerBackImage: <Image source={require('../assets/icons/back.png')}/>,
    headerBackTitle: null,
    headerLeftContainerStyle: {},
    headerRightContainerStyle: {},
  }

within the createAppContainer method immediately throws

TypeError: undefined is not an object (evaluating '_react.React.createElement')

The image is definitely at the correct location, and commenting out the headerBackImage property resolves the problem. Is this bugged?


Solution

  • please check if you're correctly importing React as the default import

    check the links below where other developers had the same issue as you and solved their problems by correcting this

    TypeError: undefined is not an object 'createElement' of undefined - React Native

    TypeError : React object is undefined on createElement

    let me know if this solves your problem