reactjs - creatreactapp & Reflux TypeError: Super expression must be null or a function
问题描述
我有一个简单的 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;
指南针.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'));
解决方案
是的,我实际上从 createreactapp 中删除了 serviceWorker,这就是原因。
推荐阅读
- php - 从php获取nodejs中的跨源资源
- laravel - 客户端错误:`POST https://graph.facebook.com/v3.0/oauth/access_token` 导致`400 Bad Request`
- python - 为什么我不能使用这样的变量 a=(1,2)
- angular - Angular - 材料/自动完成未按预期显示
- javascript - 为什么 CSS 是导入 JSX 文件而不是单独加载?
- javascript - 如何在控制器/组件中使用导入的第三方 js(不是 addon/npm 包)?
- android - 我正在使用 laravel 和 opentok 开发视频聊天应用程序。但我坚持实施一种让用户互相通话的方法
- python - 如何使用范围拆分数据列表直到列表完成其数据
- reactjs - 使用 Promise.all 和 fetch API 返回的数据动态设置状态对象:React+Typescript
- drupal-8 - Codeception - 如何在 Codeception 中从 Drupal 核心运行 phpunit 测试?