【发布时间】:2019-06-18 20:35:16
【问题描述】:
我有一个简单的 createreactapp,我想用它来测试回流,而不是 redux,我正在尝试将 Reflux 包含在其中。我检查了 .Component 和 .Store 的拼写以及类结构,但仍然。
当我运行它时,它给了我这个错误:
TypeError: Super expression 必须为 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'));
【问题讨论】: