Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide toolbar in react navigation

I want to know how to hide toolbar which is being added by default after implementation of react-navigation https://reactnavigation.org/

I have two screens - Launcher screen where I do not want a toolbar and 2nd screen where it is OK to have toolbar.

index.android.js

/**
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from "react";
import {
  AppRegistry,
  Image,
  View,
  Text,
  Button,
  StyleSheet
} from "react-native";
import { StackNavigator } from "react-navigation";
import EnableNotificationScreen from "./EnableNotification";

class SplashScreen extends Component {
  render() {
    console.disableYellowBox = true;
    const { navigate } = this.props.navigation;
    return (
      <View style={styles.container}>
        <Image source={require("./img/talk_people.png")} />
        <Text style={{ fontSize: 22, textAlign: "center" }}>
          Never forget to stay in touch with the people that matter to you.
        </Text>
        <View style={{ width: 240, marginTop: 30 }}>
          <Button
            title="CONTINUE"
            color="#FE434C"
            onPress={() => navigate("EnableNotification")}
          />
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    backgroundColor: "#FFFFFF",
    alignItems: "center",
    justifyContent: "center",
    padding: 16,
    flex: 1,
    flexDirection: "column"
  }
});

const ScheduledApp = StackNavigator(
  {
    Splash: { screen: SplashScreen },
    EnableNotification: { screen: EnableNotificationScreen }
  },
  {
    initialRouteName: "Splash"
  }
);

AppRegistry.registerComponent("Scheduled", () => ScheduledApp);

EnableNotification.js

/**
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from "react";
import { View, Text } from "react-native";

export default class EnableNotificationScreen extends Component {
  render() {
    return <View><Text>Enable Notification</Text></View>;
  }
}
like image 292
N Sharma Avatar asked Apr 24 '17 18:04

N Sharma


Video Answer


1 Answers

  static navigationOptions = {
    header: null ,
  };

this works for me

class SplashScreen extends Component {

  static navigationOptions = {
    header: null ,
  };

  render() {
    console.disableYellowBox = true;
    const { navigate } = this.props.navigation;
    return (
      ...
    );
  }
}
like image 176
wei wang Avatar answered Oct 30 '22 11:10

wei wang