Super expression must either be null or a function, not undefined 报错及解决

在 React 项目中,遇到了上面的报错信息。

Super expression must either be null or a function, not undefined

查阅资料,进行这样的分析:

// 原始代码

'use strict';

import Realm from 'realm';

class Todo extends Realm.Object {}
Todo.schema = {
    name: 'Todo',
    properties: {
        done: {type: 'bool', default: false},
        text: 'string',
    },
};

class TodoList extends Realm.Object {}
TodoList.schema = {
    name: 'TodoList',
    properties: {
        name: 'string',
        items: {type: 'list', objectType: 'Todo'},
    },
};

export default new Realm({schema: [Todo, TodoList]});

这是原始的JS代码(使用React框架)

可能的原因有以下几个:

1、确认一下React.Component是否书写正确,不是React.component或者React.Comonent…(这是我个人的问题,component 拼写错误) 

2、检查下React版本,确保更新到0.13.x及更高版本 :This is fixed in the newest version 0.13.0 which is coming out shortly. You can try the release candidate now by setting the version to 0.13.0-rc in your package.json

3、检查模块间是否存在循环依赖

4、确认导入的库是否正确

import React,{Component} from 'react';

Component 需要从原生的React 中引入,不是从 react-router中引入。

猜你喜欢

转载自blog.csdn.net/weixin_41697143/article/details/84981130