In which scenarios would you consider using the ChangeDetectionStrategy.OnPush for a component?

  • When the component interacts with external APIs.
  • When the component needs to re-render frequently.
  • When the component relies on two-way data binding.
  • When the component's data is immutable and only changes through input properties.
ChangeDetectionStrategy.OnPush is suitable when a component's data is immutable and only changes through input properties. This strategy optimizes performance by avoiding unnecessary change detection checks. It is not used when two-way data binding is required or when the component re-renders frequently. Interaction with external APIs is typically unrelated to the choice of change detection strategy.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *