Skip to content

[Feature] Provider a state property decorator. #15

@Moln

Description

@Moln

General Information

  • Bug
  • Improvement
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions