Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyComponent extends Component {
- constructor() {
- this.prop1 = this.props.prop1;
- this.prop2 = this.props.prop2;
- }
- render() {
- //....
- }
- onEvent(e) {
- this.setState({
- prop1: getProp1(),
- prop2: this.prop2()
- });
- }
- }
- class MyState {
- update(params) {
- this.prop1 = getProp1();
- }
- }
- class MyComponent extends Component {
- constructor() {
- this.state.obj = this.props.obj; // this has type MyState
- }
- render() {
- //....
- }
- onEvent(e) {
- this.obj.update(e.something);
- this.setState(this.obj);
- }
- }
Add Comment
Please, Sign In to add comment