Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace UNSAFE_componentWillReceiveProps with Modern Lifecycle Methods #661

Open
wants to merge 1 commit into
base: v1
Choose a base branch
from

Conversation

ThreePalmTrees
Copy link

Issue

This change removes the React warning:

Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles for details.

* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state

Please update the following components: Tour

Changes

  • Replaced the deprecated UNSAFE_componentWillReceiveProps with modern React lifecycle methods
  • Split the logic between static getDerivedStateFromProps for state updates and componentDidUpdate for side effects
  • Maintained the same functionality while removing the React warning

Technical Details

  • Added static getDerivedStateFromProps to handle state updates based on prop changes:
    • Tour opening/closing state
    • Current step updates
    • GoToStep functionality
  • Added componentDidUpdate to handle side effects:
    • Calling open() and close()
    • Handling step updates with timeouts
    • Calling onRequestClose

The changes maintain the same behavior while removing the deprecated lifecycle method warning. The tour should continue to:

  • Open and close properly
  • Update steps correctly
  • Handle step navigation
  • Maintain all existing functionality

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant