0.1.7 • Published 5 years ago
erc2 v0.1.7
(ERC) Extended React Component
Set properties in React Components like in Angular
All you need, is define this.s
this.s equal this.state, but now you can set properties like this:
this.s = {
test: 1
};
// console.log(this.s.test);
// -> 1
this.s.test = 2;
// console.log(this.s.test);
// -> 2
this.setState({
test: 3
});
// console.log(this.s.test);
// -> 3
this.state = {
test: 4
};
// console.log(this.s.test);
// -> 4
this.s.test = 5;
// console.log(this.state.test);
// -> 5Example:
import React from "react";
import {ExtendedComponent} from "erc2";
class IndexComponent extends ExtendedComponent {
constructor(props) {
super(props);
this.s = {
test: 1,
};
setTimeout(() => {
this.setState({
test: 2
});
setTimeout(() => {
this.s.test = 3;
}, 1000);
}, 1000);
}
render() {
return (
<div className="index-page">
<div>
this.s.test: {this.s.test}
</div>
<div>
this.state.test: {this.state.test}
</div>
</div>
);
}
}0.1.7
5 years ago
0.1.4
5 years ago
0.1.6
5 years ago
0.1.5
5 years ago
0.1.3
5 years ago
0.1.2
5 years ago
0.1.1
6 years ago
0.0.12
6 years ago
0.1.0
6 years ago
0.0.10
6 years ago
0.0.11
6 years ago
0.0.9
6 years ago
0.0.8
6 years ago
0.0.5
6 years ago
0.0.7
6 years ago
0.0.6
6 years ago
0.0.4
6 years ago
0.0.3
6 years ago
0.0.2
6 years ago
0.0.1
6 years ago