国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

javascript - react-native在chrome調試工具中出現警告,并且不能使用react dev-tools

瀏覽:157日期:2022-11-05 15:08:56

問題描述

1.我使用react@16.0.0-alpha.12, react-native@0.45.1 ,在模擬是可以正常使用的,但是在chrome調試工具中出現了警告:

ExceptionsManager.js:71 Warning: PropTypes has been moved to a separate package. Accessing React.PropTypes is no longer supported and will be removed completely in React 16. Use the prop-types package on npm instead. (https://fb.me/migrating-from-react-proptypes)

ExceptionsManager.js:71 Warning: React.createClass is no longer supported. Use a plain JavaScript class instead. If you’re not yet ready to migrate, create-react-class is available on npm as a drop-in replacement. (https://fb.me/migrating-from-react-create-class)

并且不能使用react dev-tools 進行調試

我的代碼:

/** * Sample React Native App * https://github.com/facebook/react-native * @flow */import React, { Component } from ’react’import { AppRegistry, View, Text, StyleSheet} from ’react-native’export default class second extends Component{ render () { return ( <View style={{ flex: 1,flexDirection: ’column’,justifyContent: ’center’,alignItems: ’center’,backgroundColor: ’ghostwhite’ }}><Text style={{fontSize: 28, color: ’cadetblue’}}>class extends</Text> </View> ) } componentDidMount () { console.log(’==========’) this.testConsolelog() } testConsolelog () { console.log(’e3423423432’) }}const styles2 = StyleSheet.create({ bigblue: { color: ’blue’, fontWeight: ’bold’, fontSize: 30, }, red: { color: ’red’, },});AppRegistry.registerComponent(’second’, () => second);

問題解答

回答1:

你用的react16中,已經棄用了React.createClass這個方法。

因此react16的版本就無法通過該方法來創建組件了。你必須使用ES6的方式來創建組件了。

class Test extends React.Component { ...}

如果你的代碼中用了mixins而必須使用createClass的話,你需要單獨引入另外一個工具庫。

var createReactClass = require(’create-react-class’);

另外,React.propTypes也不能使用了,你想要檢測props,react16中需要引入一個單獨的工具。

import PropTypes from ’prop-types’;回答2:

不能使用react dev-tools, 是不是沒有勾選允許訪問文件地址

javascript - react-native在chrome調試工具中出現警告,并且不能使用react dev-tools

標簽: JavaScript
主站蜘蛛池模板: 石城县| 云霄县| 宣威市| 汉寿县| 阿拉善右旗| 乐安县| 汉阴县| 南溪县| 乌苏市| 南丹县| 招远市| 高平市| 朝阳县| 长顺县| 巴林右旗| 曲松县| 正阳县| 蓝田县| 吉林市| 株洲县| 大埔县| 汉寿县| 昭苏县| 昭觉县| 个旧市| 通州区| 天水市| 建昌县| 贡嘎县| 松溪县| 土默特左旗| 林州市| 循化| 屏东县| 武邑县| 宜昌市| 金塔县| 宁化县| 卓尼县| 清水河县| 北宁市|