Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Provider a state property decorator. #15

Open
1 of 4 tasks
Moln opened this issue Mar 25, 2020 · 1 comment
Open
1 of 4 tasks

[Feature] Provider a state property decorator. #15

Moln opened this issue Mar 25, 2020 · 1 comment

Comments

@Moln
Copy link

Moln commented Mar 25, 2020

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

@mbasso
Copy link
Owner

mbasso commented Mar 27, 2020

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 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants