原因是react 16将createClass移除了,使用es6语法,如果必须使用es5创建类的话,请使用create-react-class包,请参考
var React = require("react");
var createReactClass = require('create-react-class');
import {
StyleSheet,
View,
Text
} from 'react-native';
var MyComponent = createReactClass({
render() {
return (
<View style={styles.container}>
<Text>dsaads</Text>
</View>
)
}
});
const styles = StyleSheet.create({
container: {
display: 'flex',
flex: 1,
backgroundColor: '#ccc'
}
});
module.exports = MyComponent;