0.1.7 • Published 4 years ago

erc2 v0.1.7

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

(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);
// -> 5

Example:

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

4 years ago

0.1.4

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.0.12

4 years ago

0.1.0

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.5

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago