本文介绍了警告:在简单的Javascript类中不推荐使用isMounted(...)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用react-navigation实现2个屏幕。但是在导航到第二页时我收到了以下警告:

I am implementing 2 screens using react-navigation. But I got the warning below while navigating to the second page:

版本:


  • react:16.3.1

  • react-native:0.55.2

  • react -navigation:1.5.11

  • util:0.10.3

  • react: 16.3.1
  • react-native: 0.55.2
  • react-navigation: 1.5.11
  • util: 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>
    )
}

Home.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>
        )
    }
}

我在这里缺少什么?

推荐答案

这是最新的React Navigation和React Native的问题。要沉默它,请添加:

This is a problem with latest React Navigation and React Native. To silence it add:

import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader']);

我预计它将在未来几周内在React Navigation中修复。

I expect it will be fixed in React Navigation within next few weeks.

这篇关于警告:在简单的Javascript类中不推荐使用isMounted(...)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-04 05:38