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

New lint: potential bug with assigning a value to a tracked property #1925

Open
NullVoxPopuli opened this issue Aug 7, 2023 · 0 comments
Open
Labels
enhancement New Rule Idea for a new lint rule

Comments

@NullVoxPopuli
Copy link
Contributor

Example:

class Demo extends Component {
  @tracked foo = this.someProperty

  @cached 
  get someProperty() {
    return this.args.someData ?? [];
  }
}

The bug is that we expect foo to initially be someProperty, but someData may not yet be available and we end up setting [] as the value of foo on first render.

Since property assignment is non-reactive, we should warn of this bug, and suggest using @localCopy from https://github.com/tracked-tools/tracked-toolbox
so that changes to someProperty used in foo

@bmish bmish added enhancement New Rule Idea for a new lint rule labels Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New Rule Idea for a new lint rule
Projects
None yet
Development

No branches or pull requests

2 participants