1

I have 4 components which all have static navigationOptions = {header: null} defined. But that it's very time-consuming when you define that in each component. So I define {header: null} in createStackNavigator but the header still appears at the top of the component.

Can you guys help ?

import { createStackNavigator } from 'react-navigation';
import Home from './Components/Home';
import Main from './Components/Main';
import SubjectDetail from './Components/AnimalSubject';
import Lesson from "./Components/Lesson";

const App = createStackNavigator({
     First: { screen: Home },
     Second: { screen: Main },
     Third: { screen: SubjectDetail },
     Four: {screen: Lesson},
//Route name with specified component
},
{
     transitionConfig: () => ({ screenInterpolator: () => null }),
//remove transition config
},
{
     initialRouteName: 'First',
//the component name 'Home' will be initiated first
},
{
     header: null
//defined header: nul
}
);

export default App;

my evironment

"react": "16.3.1",
"react-native": "~0.55.2",
"react-navigation": "^2.2.5",
"node": "v8.11.2"
"npm": "v6.1.0"
Dee_wab
  • 1,171
  • 1
  • 10
  • 23
STEPHEN bui
  • 579
  • 1
  • 9
  • 27

1 Answers1

3

Probably this code should works for you (based on Stack navigator docs)

const App = createStackNavigator({
     First: { screen: Home },
     Second: { screen: Main },
     Third: { screen: SubjectDetail },
     Four: {screen: Lesson},
},
{
     headerMode: 'none',
     transitionConfig: () => ({ screenInterpolator: () => null }),
     initialRouteName: 'First',
},
);

You should pass the object with routes as a first parameter and common options as second.