reflux / refluxjs

A simple library for uni-directional dataflow application architecture with React extensions inspired by Flux
BSD 3-Clause "New" or "Revised" License
5.36k stars 330 forks source link

Error: Super expression must either be null or a function, not undefined #502

Closed zaxlct closed 7 years ago

zaxlct commented 7 years ago

reflux v0.4.1 react v15.1.0

var Actions1 = Reflux.createActions(["increment"]);
var Actions2 = Reflux.createActions(["decrement"]);

class DeviceInfoSR extends Reflux.Store {
    constructor() {
        super();
        this.listenables = [Actions1, Actions2];
        this.state = {count:0};
    }

    onIncrement() {
        var cnt = this.state.count;
        this.setState({count:cnt+1});
    }

    onDecrement() {
        var cnt = this.state.count;
        this.setState({count:cnt-1});
    }
}

class DeviceInfo extends Reflux.Component {
    constructor(props) {
        super(props);
        this.state = {};
        this.store = DeviceInfoSR; // <- just assign the class itself
    }

    render() {
        return <p>Count: {this.state.count}</p>;
    }
}

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

WHY ???

eek commented 7 years ago

The first problem I see is that you're using extends Reflux.Store which does not exist in reflux v0.4.1, it exists from reflux v5.0.0 so update to the latest and try again :)

zaxlct commented 7 years ago

Tnanks