Skip to main content
InterviewHubPRO
Section Overview
Q243

Question 243 of 407

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

60%
React Core & Hooks (407 Qs)•Part 8: Advanced React Patterns, Portals & Performance (152 - 261)

What is the benefit of strict mode?

junior LevelCode ExampleFormsPerformance

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>