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

WIP Refactor useMotionRef for Improved Lifecycle Mgmt #2283

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

Conversation

gurkerl83
Copy link

Enhanced the useMotionRef hook in the following ways:

  1. Introduced useEffect to ensure the systematic unmounting of visualElement during the component's unmount phase. This change provides cleaner management of resources, especially in scenarios involving asynchronous operations like React.lazy and Suspense.

  2. Streamlined the lifecycle management of visualState and visualElement based on the presence of the instance variable (representing a DOM node). This modification aims to offer more robust handling in contexts where promises from React.lazy might render certain child components invalid.

Detailed documentation comments have been added to highlight the importance and rationale behind the changes. These comments elucidate the potential pitfalls and provide clearer insights into the logic's behavior, especially concerning asynchronous component loading.

Enhanced the `useMotionRef` hook in the following ways:

1. Introduced `useEffect` to ensure the systematic unmounting of `visualElement` during the component's unmount phase. This change provides cleaner management of resources, especially in scenarios involving asynchronous operations like React.lazy and Suspense.

2. Streamlined the lifecycle management of `visualState` and `visualElement` based on the presence of the `instance` variable (representing a DOM node). This modification aims to offer more robust handling in contexts where promises from React.lazy might render certain child components invalid.

Detailed documentation comments have been added to highlight the importance and rationale behind the changes. These comments elucidate the potential pitfalls and provide clearer insights into the logic's behavior, especially concerning asynchronous component loading.
@gurkerl83
Copy link
Author

Fixes #2269

@gurkerl83
Copy link
Author

Unfortunately many tests fail now

@gurkerl83 gurkerl83 changed the title Refactor useMotionRef for Improved Lifecycle Mgmt [Do Not Merge] Refactor useMotionRef for Improved Lifecycle Mgmt Aug 11, 2023
@gurkerl83 gurkerl83 changed the title [Do Not Merge] Refactor useMotionRef for Improved Lifecycle Mgmt [WIP] Refactor useMotionRef for Improved Lifecycle Mgmt Aug 11, 2023
@gurkerl83 gurkerl83 changed the title [WIP] Refactor useMotionRef for Improved Lifecycle Mgmt WIP Refactor useMotionRef for Improved Lifecycle Mgmt Aug 11, 2023
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.

None yet

1 participant