Share Your Experience With Others

@track Vs @api decorators in LWC

@track decorator

  • To track a private property’s value
  • rerender a component when it changes
  • Tracked properties are also called private reactive properties.

@api decorator

  •  To expose a public property
  • Can be set by another component

Note : Both @track and @api mark a property as reactive. If the property’s value changes, the component rerenders.

Leave a comment