Salesforce Decode
Salesforcedecode
Back to questions
LWCBeginnerapitrackreactivity

What is the difference between @api and @track?

Real World Scenario

A parent passes a record Id to a child component. You explain public properties and reactivity.

Expected Answer

• @api marks public properties the parent can set from markup or other components • Primitive @api properties are reactive by default in modern LWC • @track was needed for deep reactivity on object properties; plain fields are reactive now for most cases • Use @api for inputs from parent; internal state uses class fields • Clear naming helps parent-child contracts stay maintainable

Follow-Up Questions & Answers

Click to expand — each follow-up includes a direct, interview-ready answer

Rarely on modern API versions for deep object mutation edge cases. Prefer spreading objects to trigger re-render when unsure.

Architect Perspective

If asked @track, show you know it is mostly legacy—signals current LWC knowledge.