Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 1.22 KB

no-tracked-properties-from-args.md

File metadata and controls

37 lines (25 loc) · 1.22 KB

ember/no-tracked-properties-from-args

💼 This rule is enabled in the ✅ recommended config.

Disallow creation of @tracked properties from args.

Rule Details

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

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;
    }
}

References