creatreactapp和Reflux TypeError:超级表达式必须为null或函数

时间:2019-01-25 01:57:33

标签: reactjs refluxjs

我有一个简单的createreactapp,我想用它来测试回流,而不是redux,并且我正在尝试将Reflux包含进去。我检查了.Component和.Store以及类结构的拼写,但是仍然如此。

运行它会给我这个错误:

TypeError:超级表达式必须为null或函数。

回流对于createreactapp是否太老了? 是webpack错误吗? 通天塔?

完整错误:

inherits.js:4 Uncaught TypeError: Super expression must either be null or a 
function
    at _inherits (inherits.js:4)
    at statStore.js:7
    at Module../src/statStore.js (statStore.js:7)
    at __webpack_require__ (bootstrap:782)
    at fn (bootstrap:150)
    at Module../src/Compass.js (index.css:8)
    at __webpack_require__ (bootstrap:782)
    at fn (bootstrap:150)
    at Module../src/index.js (index.css?02e3:45)
    at __webpack_require__ (bootstrap:782)
    at fn (bootstrap:150)
    at Object.0 (statStore.js:42)
    at __webpack_require__ (bootstrap:782)
    at checkDeferredModules (bootstrap:45)
    at Array.webpackJsonpCallback [as push] (bootstrap:32)
    at main.chunk.js:1

stateStore.js

import React from 'react';
import actions from './actions';
import Reflux from 'reflux';



class statStore extends Reflux.Store {


    constructor(props){
        super(props);
        this.state = {
            status:0
        }
        this.listenables = actions;




    }


    onStateUpdate2(){

        this.setState({status:2})
        console.log('stateupdate2')
    }


    onStateUpdate3(){

        this.setState({status:3})
        console.log('stateupdate3')
    }




}


export default statStore;

compass.js

import React from 'react';
import actions from './actions';
import statStore from './statStore';
import Reflux from 'reflux';


class Compass extends Reflux.Component {



    constructor(props){
        super(props);
        //this.store = statStore;
    }





    render(){


        console.log('BAHAHHA')

        return(<div onClick={actions.stateUpdate2}>{this.state.status}</div>)



    }



}


export default Compass;

index.js

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import Compass from './Compass';


ReactDOM.render(<Compass />, document.getElementById('root'));

1 个答案:

答案 0 :(得分:0)

是的,我实际上从createreactapp中删除了serviceWorker,这就是原因。