💼 This rule is enabled in the ✅ recommended
config.
Disallow creation of @tracked properties from args.
This rule disallows the creation of @tracked properties with values from this.args
. The @tracked property will not be updated when the args change, which is almost never what you want. Instead, use a getter to derive the desired state.
If you need to modify a specific arg, consider having the parent provide a way for the child component to update it. This avoids having two sources of truth that you will need to keep in sync.
Examples of incorrect code for this rule:
class Example {
@tracked someValue = this.args.someValue;
}
Examples of correct code for this rule:
class Example {
get someValue() {
return this.args.someValue;
}
}
- Glimmer Components - args guide
- tracked guide