1. I use react@16.0.0-alpha.12
, react-native@0.45.1
, which can be used normally in simulation, but in the chrome debugging tool A warning appeared in:
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)
And cannot use react dev-tools for debugging
My code:
/**
* 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);
In the react16 you are using, the method
React.createClass
has been deprecated.So the react16 version cannot create components through this method. You must use the ES6 way to create components.
If you use mixins in your code and must use
createClass
, you need to introduce another tool library separately.In addition,
React.propTypes
can no longer be used. If you want to detect props, a separate tool needs to be introduced in react16.You can’t use react dev-tools, is it because you don’t have check the box to allow access to file addresses