« Back to Search  |  Reader Mode  |  Switch to Full Retro Site View Links: Stay in Reader  |  Retro Mode: ON  |  Original »
GitHub · Extracted in 1797 ms

fix: migrate deprecated componentWillReceiveProps to componentDidUpdate by 18vikastg · Pull Request #798 · algorithm-visualizer/algorithm-visualizer

Source: https://github.com/algorithm-visualizer/algorithm-visualizer/pull/798

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 componentWillReceiveProps with componentDidUpdate in App, Navigator, Player, FoldableAceEditor, VisualizationViewer, and ToastContainer components to ensure compatibility with modern React best practices. [1] [2] [3] [4] [5] [6]

Workspace state persistence:

  • Added logic in App to load and persist workspace preferences (navigatorOpened and workspaceWeights) using localStorage, 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 ToastContainer to 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 FoldableAceEditor so 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 componentWillReceiveProps with componentDidUpdate in App, Navigator, Player, ToastContainer, FoldableAceEditor, and VisualizationViewer components, ensuring compatibility with newer React versions and improving reliability. [1] [2] [3] [4] [5] [6]

Workspace persistence improvements

  • Added logic in App to load and persist workspace preferences such as navigator visibility and workspace weights using localStorage, allowing users' UI state to be remembered across sessions. [1] [2]

Keyboard shortcut enhancements

  • Implemented keyboard shortcuts in Player for 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 Player and ToastContainer components on unmount, preventing potential memory leaks. [1] [2]

Component-specific update logic

  • Improved update logic in FoldableAceEditor and VisualizationViewer to 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

Labels

None yet

2 participants