美文网首页
TypeError: undefined is not a fu

TypeError: undefined is not a fu

作者: 青子衿S | 来源:发表于2020-03-09 10:39 被阅读0次
报错信息

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

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

相关文章

网友评论

      本文标题:TypeError: undefined is not a fu

      本文链接:https://www.haomeiwen.com/subject/bvrudhtx.html