This example demonstrates how dva applications work correctly in React 18 Strict Mode, including proper cleanup and double-rendering behavior.
- Strict Mode Compatibility: Application runs without warnings in Strict Mode
- Effect Cleanup: Proper cleanup of subscriptions and timers
- Double Rendering Handling: Components handle React 18's double-rendering correctly
- Resource Management: Proper cleanup of resources on unmount
React 18 Strict Mode helps identify potential issues by:
- Intentionally double-invoking effects in development
- Detecting unsafe lifecycles
- Ensuring proper cleanup patterns
- Subscriptions with proper unlistener functions
- Timer cleanup with clearInterval/clearTimeout
- Event listener removal
cd examples/react18-strict-mode
npm install
npm start- Console Output: Notice the double-rendering behavior in development
- Effect Cleanup: Verify timers and subscriptions are cleaned up
- No Warnings: Application should run without React warnings
- State Consistency: State remains consistent across renders
index.js: Application setup with Strict Mode wrapperApp.js: Main component demonstrating Strict Mode patternsREADME.md: This documentation