React Navigation:尝试在stackNavigator中格式化标头时出错

时间:2018-01-11 00:30:11

标签: react-native react-navigation

我的代码是here 我正在尝试使用以下代码段删除后退按钮

    navigationOptions: {
      title: 'Dashboard',
      header: {
    left: null,
            }
      }
    }
});

但是我收到以下错误:

enter image description here

整个文件都在这里

import { StackNavigator, TabNavigator } from 'react-navigation';

// Home scenes
import Home from '../scenes/Home';

// Authentication scenes
import Login from '../scenes/authentication/Login';
import SignUpStep from '../scenes/authentication/SignUpStep';
import SelectTeachers from '../scenes/authentication/SelectTeachers';

// import Dashboard from '../components/Dashboard'
// import FeedScreen from '../components/FeedScreen'
import AwardsScreen from '../scenes/award/AwardsScreen';
// import StudentsScreen from '../components/StudentsScreen'
import GameOnScreen from '../scenes/game/GameOnScreen';

// All practice scenes
import AllPractice from '../scenes/practice/AllPractice';
import Practice from '../scenes/practice/Practice';
import PlayingTests from '../scenes/practice/PlayingTests';
import Questions from '../scenes/practice/Questions';
import Individuals from '../scenes/practice/Individuals';

// Group
import Groups from '../scenes/group/Groups';

// Upload
import UploadsScreen from '../scenes/upload/UploadsScreen';
import Pending from '../scenes/upload/Pending';

// Constant for tab menus
const submissionMenu = {
  screen: TabNavigator({
    All: { screen: AllPractice },
    Practice: { screen: Practice },
    PlayingTests: { screen: PlayingTests },
    Questions: { screen: Questions }
  }, {
    tabBarPosition: 'top',
    flex: 2 / 3,
    tabBarOptions: {
      activeBackgroundColor: '#33ACDE',
      activeTintColor: 'white'
    }
  }
  )
};
const studentMenu = {
  screen: TabNavigator({
    Individuals: { screen: Individuals },
    Groups: { screen: Groups },
    Pending: { screen: Pending }
  }, {
    tabBarPosition: 'top',
    flex: 1 / 2,
    tabBarOptions: {
      activeBackgroundColor: '#33ACDE',
      activeTintColor: 'white'
    }
  }
  )
};

// Navigation defined
const navigator = StackNavigator({
  home: { screen: Home },
  signup: { screen: SignUpStep },
  login: { screen: Login },
  selectTeachers: { screen: SelectTeachers },
  dashboard: {

    screen: TabNavigator({
      Submissions: submissionMenu,
      Students: studentMenu,
      Awards: { screen: AwardsScreen },
      GameOn: { screen: GameOnScreen },
      Uploads: { screen: UploadsScreen }
    }, {
      tabBarPosition: 'bottom',
      flex: 1 / 2,
      tabBarOptions: {
        activeBackgroundColor: '#33ACDE',
        activeTintColor: 'white'
      }
    }),
    navigationOptions: {
      title: 'Dashboard',
      header: {
    left: null,
            }
      }
    }
});

export default navigator;

1 个答案:

答案 0 :(得分:0)

似乎这段代码有效:

navigationOptions: {
  title: 'Test',
  headerLeft: null

  }

感谢您对此进行调查。