blob: de4a743cefb5bbdf37af9e471395eea3d9f7bab8 [file] [log] [blame]
class Component {
constructor(props = {}) {
this.props = props;
this.prevProps = {};
this.state = {};
}
setState(nextState, cb = () => {}) {
if (typeof nextState === "function") {
this.state = {
...this.state,
...nextState(this.state),
};
} else {
this.state = {
...this.state,
...nextState,
};
}
cb();
if (this.render) {
this.render();
}
}
}