简体   繁体   中英

React-Navigation StackNavigator header not showing

I'm trying to get the StackNavigator to work from react-navigation.org

I have another app that I'm successfully using TabNavigator which shows up fine.

Things I've tried so far to try and get this to work..

  • Copied the code literally line by line, no change
  • Checked each package version with yarn, no change
  • Moved the AppRegistry, no change

Not sure what to try next...

index.ios.js

import App from './src/App'

/src/App.js

/* @flow */

import {AppRegistry} from 'react-native'
import QuestionList from './questionRow/QuestionList'
import React from 'react'
import {StackNavigator} from 'react-navigation'

export default class App extends React.Component {
    static navigationOptions = {
        title: 'Questions',
    }

    state = {}

    render() {
        return <QuestionList />
    }
}

const AIBUApp = StackNavigator({
    Home: {screen: App},
})

AppRegistry.registerComponent('aibu', () => App)

Any ideas?

I wasn't doing the correct App Registry.

Should have been...

AppRegistry.registerComponent('aibu', () => AIBUApp)

Doesn't matter where you place this, can either be in the App.js or the index.ios/android.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM