InterviewHubPRO
Section Overview
Q243

Question 243 of 445

Part 8: Advanced React Patterns, Portals & Performance (152 - 261)

55%
React & Modern Frontend (445 Qs)•Part 8: Advanced React Patterns, Portals & Performance (152 - 261)

What is the benefit of strict mode?

The <StrictMode> will be helpful in the below cases,

  1. To find the bugs caused by impure rendering where the components will re-render twice.
  2. To find the bugs caused by missing cleanup of effects where the components will re-run effects one more extra time.
  3. Identifying components with unsafe lifecycle methods.
  4. Warning about legacy string ref API usage.
  5. Detecting unexpected side effects.
  6. Detecting legacy context API.
  7. Warning about deprecated findDOMNode usage

Practical Code Example

jsx
// StrictMode benefits:
// In development, React double-invokes render and effects to expose accidental side-effects:
<React.StrictMode>
  <App />
</React.StrictMode>