fix: migrate deprecated componentWillReceiveProps to componentDidUpdate by 18vikastg · Pull Request #798 · algorithm-visualizer/algorithm-visualizer
Repository navigation
fix: migrate deprecated componentWillReceiveProps to componentDidUpdate - #798
Open
18vikastg wants to merge 1 commit into algorithm-visualizer:master from 18vikastg:fix/deprecated-lifecycle-methods
Open
fix: migrate deprecated componentWillReceiveProps to componentDidUpdate #798 18vikastg wants to merge 1 commit into algorithm-visualizer:master from 18vikastg:fix/deprecated-lifecycle-methods
Conversation
18vikastg commented Oct 16, 2025
Copy link Copy Markdown
This pull request refactors several React component lifecycle methods to use componentDidUpdate instead of the deprecated componentWillReceiveProps, and introduces persistent workspace state and improved event handling. These changes enhance code maintainability, user experience, and future compatibility.
Lifecycle method modernization:
- Replaced
componentWillReceivePropswithcomponentDidUpdateinApp,Navigator,Player,FoldableAceEditor,VisualizationViewer, andToastContainercomponents to ensure compatibility with modern React best practices. [1] [2] [3] [4] [5] [6]
Workspace state persistence:
- Added logic in
Appto load and persist workspace preferences (navigatorOpenedandworkspaceWeights) usinglocalStorage, so user layout choices are retained across sessions. [1] [2]
Event handling improvements:
- In
Player, added keyboard shortcuts for play/pause (space), previous (left arrow), and next (right arrow) actions, and window resize handling, improving accessibility and usability. Also added cleanup for event listeners on unmount.
Toast notification timing fix:
- Refactored
ToastContainerto correctly handle toast timeouts and cleanup, ensuring toasts disappear after the intended delay and preventing memory leaks.
Editor folding logic refinement:
- Improved folding logic in
FoldableAceEditorso tracers are folded only when appropriate, reducing unnecessary operations.- Replaced componentWillReceiveProps with componentDidUpdate in 6 components
- Added proper prevProps comparison to prevent unnecessary updates
- Ensures compatibility with React 17+ and future versions
Resolves deprecation warnings and future-proofs the codebase.
This pull request refactors several React components to replace the deprecated componentWillReceiveProps lifecycle method with the recommended componentDidUpdate. It also adds new workspace persistence features and keyboard shortcuts, improving user experience and code maintainability.
Lifecycle method modernization
- Replaced all usages of
componentWillReceivePropswithcomponentDidUpdateinApp,Navigator,Player,ToastContainer,FoldableAceEditor, andVisualizationViewercomponents, ensuring compatibility with newer React versions and improving reliability. [1] [2] [3] [4] [5] [6]
Workspace persistence improvements
- Added logic in
Appto load and persist workspace preferences such as navigator visibility and workspace weights usinglocalStorage, allowing users' UI state to be remembered across sessions. [1] [2]
Keyboard shortcut enhancements
- Implemented keyboard shortcuts in
Playerfor play/pause (space), previous (left arrow), and next (right arrow) actions, improving accessibility and user interaction.
Resource management
- Ensured proper cleanup of event listeners and timeouts in
PlayerandToastContainercomponents on unmount, preventing potential memory leaks. [1] [2]
Component-specific update logic
- Improved update logic in
FoldableAceEditorandVisualizationViewerto correctly respond to prop changes by folding tracers or updating visualizations only when relevant data changes. [1] [2]
fix: migrate deprecated componentWillReceiveProps to componentDidUpdate
26448c4
- Replaced componentWillReceiveProps with componentDidUpdate in 6 components - Added proper prevProps comparison to prevent unnecessary updates - Ensures compatibility with React 17+ and future versions Resolves deprecation warnings and future-proofs the codebase.
hanumanthuNani commented Dec 26, 2025
Copy link Copy Markdown
|
Great refactor overall -- replacing componentWillReceiveProps with componentDidUpdate across multiple components significantly improves future compatibility and removes deprecation warnings. The workspace state persistence via localStorage and the added keyboard shortcuts are thoughtful UX improvements, and the added cleanup logic helps avoid potential memory leaks. Nice work keeping updates scoped with proper prevProps checks. |
This branch has not been deployed
No deployments
Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment