Performance & Optimization Flashcards
1
Q
Why is using the index as a key in React lists a bad idea?
A
If the list order changes, it can lead to performance issues and bugs as React uses keys to reconcile the DOM.
2
Q
How can you prevent a component from re-rendering?
A
Using React.memo() for functional components or shouldComponentUpdate lifecycle method for class components.
3
Q
Name some tools you can use to diagnose performance issues in React apps.
A
React DevTools, Chrome DevTools, the Profiler API, and Lighthouse.