react-decoration icon indicating copy to clipboard operation
react-decoration copied to clipboard

[Feature] Provider a state property decorator.

Open Moln opened this issue 5 years ago • 1 comments
trafficstars

General Information

  • [ ] Bug
  • [ ] Improvement
  • [x] Feature
  • [ ] Other

Description

For simply use state properties.

@component()
export default class Hello extends Component<{name: string}, any> {
  @state()
  name = this.props.name;

  @state()
  age: number = 20;

  render() {
    console.log("render hello");
    return (
      <div>
        Hello {this.name}, age: {this.age}
        <br />
        <button onClick={this.handleClick}>Incr age</button>
      </div>
    );
  }

  private handleClick = () => {
    this.age++;
  };
}

Steps to reproduce

https://codesandbox.io/s/provider-a-state-property-decorator-r8yh3

Moln avatar Mar 25 '20 10:03 Moln

Hi @Moln, cool, thank you for sharing! I am a little bit busy at the moment and I cannot implement it soon. Are you interested in following through with a PR? Otherwise, I will do it when it will be possible 😄

mbasso avatar Mar 27 '20 12:03 mbasso