TypeError: undefined is not a function (near... react.default.createClass..')

报错信息

原因是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 (
            
                Hello World
            
        )
    }
});

const styles = StyleSheet.create({
    container: {
        display: 'flex',
        flex: 1,
        backgroundColor: '#ccc'
    }
});
module.exports = MyComponent;

你可能感兴趣的:(TypeError: undefined is not a function (near... react.default.createClass..'))