Ich verwende Reagieren Navigation für meine App-Entwicklung. Wenn ich log-android starte, protokolliert es so etwas.Konsolenanmeldung deaktivieren Reagieren Navigation
Navigation Versand: Aktion: {...}, New State: {...}
, die von createNavigationContainer.js Linie 150.
Ich habe durch Github laufen und Dokument sagte, es könnte getan werden, indem onNavigationStateChange = {null} auf einem Top-Level-Navigator gesetzt wird.
Wie kann ich dies erreichen, indem onNavigationStateChange = {null} und wo soll ich es setzen?
Ich habe versucht, wie unten zu setzen, aber es wird die Seite nicht auf andere Seite umleiten können.
export default() => {
<App onNavigationStateChange={null} />
}
Im Folgenden sind meine app.js Code
import React, { Component } from 'react';
import { AppRegistry, StyleSheet, Text, View } from 'react-native';
import { StackNavigator,DrawerNavigator } from 'react-navigation';
import DrawerContent from './components/drawer/drawerContent.js';
import News from './components/news/home.js';
const drawNavigation = DrawerNavigator(
{
Home : {
screen : News ,
navigationOptions : {
header : null
}
}
},
{
contentComponent: props => <DrawerContent {...props} />
}
)
const StackNavigation = StackNavigator({
Home : { screen : drawNavigation,
navigationOptions: {
header: null
}
}
});
export default StackNavigation;
Das ist mein drawerContent.js ist
import React, {Component} from 'react'
import {View,Text, StyleSheet,
TouchableNativeFeedback,
TouchableOpacity,
TouchableHighlight
} from 'react-native'
import { DrawerItems, DrawerView } from 'react-navigation';
import Icon from 'react-native-vector-icons/Octicons';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
class DrawerContent extends Component {
constructor(props){
super(props);
console.log('DrawerContent|testtttttt');
}
render(){
return (
<View style={styles.container}>
<Text>Hi darren</Text>
<TouchableOpacity style={{ marginBottom:5 }} onPress={() => this.props.navigation.navigate('RegistrationScreen') } >
<View style={styles.nonIconButton}>
<Text style={{ color: 'black',fontSize: 13 }} >Sign Up</Text>
</View>
</TouchableOpacity>
<Text>Hi darren</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
export default DrawerContent;
Ich habe keine Ahnung, warum die Standardfunktion onNavigationStateChange so viel protokolliert, obwohl es eine langsamere Leistung kostet. Macht keinen Sinn –