What are @api reactive properties in LWC and how do they differ from private properties?
Suggested answer
@api properties: Public, reactive, and accessible by parent components and Lightning App Builder. When a parent changes an @api property, the child re-renders. Primitive @api properties are passed by value; objects/arrays are passed by reference (but the child should not mutate them — use a local copy). Methods decorated with @api can be called from parents via template refs. Private properties (no decorator, or @track for internal reactivity): Only accessible within the component. In modern LWC (API version 39+), all primitive properties are reactive by default — the component re-renders when they change. For nested object/array mutations, assign a new reference to trigger re-render: this.data = { ...this.data, name: 'New' }; or use @track for the property. @track forces reactivity tracking for deep object changes.
Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.
Community comments (0)
No comments yet.
Sign in or create a free account to add a comment. Comments are moderated before they appear.