我正在使用反应导航实现 2 个屏幕。但是我在导航到第二页时收到了以下警告:
警告:isMounted(…) 在纯 Javascript 类中已弃用。相反,请确保清理 componentWillUnmount 中的订阅和挂起的请求,以防止内存泄漏。
版本:
- 反应:16.3.1
- 反应本机:0.55.2
- 反应导航:1.5.11
- 效用:0.10.3
登录.js
import React, { Component } from 'react';
import { Text, View, Image, TextInput, TouchableOpacity } from 'react-native';
import styles from "./styles";
export default class Login extends Component {
constructor(props) {
super(props);
}
render() {
const { navigate } = this.props.navigation;
return (
<View style={styles.container}>
<View style={styles.formContainer}>
<TouchableOpacity style={styles.button} onPress={()=> navigate('Home')} >
<Text style={styles.buttonText}>LOGIN</Text>
</TouchableOpacity>
</View>
</View>
)
}
首页.js
import React, { Component } from 'react';
import { Text, View } from 'react-native';
import styles from "./styles";
export default class Home extends Component {
constructor(props) {
super(props);
}
render() {
const { navigate } = this.props.navigation;
return(
<View style={styles.container}>
<Text>Home Screen</Text>
</View>
)
}
}
我在这里错过了什么?
原文由 Javascript Hupp Technologies 发布,翻译遵循 CC BY-SA 4.0 许可协议
这是最新的 React Navigation 和 React Native 的问题。要使其静音,请添加:
我希望它会在接下来的几周内在 React Navigation 中得到修复。