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

Fix: Ensure TransformComponent Handles Conditional Rendering Gracefully #520

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

Conversation

mhryshkin
Copy link

This PR resolves issue #516, addressing an error where components are not mounted when TransformComponent is rendered conditionally or delayed.

Changes:

  • Added a safeguard to handle cases where wrapperComponent or contentComponent are unavailable by returning default position values.
  • This ensures compatibility and flexibility when using TransformComponent at any depth within the React tree, regardless of its conditional rendering.

@mhryshkin mhryshkin requested a review from prc5 as a code owner December 8, 2024 17:08
@@ -67,7 +67,12 @@ export const calculateBounds = (
const { centerZoomedOut } = contextInstance.setup;

if (!wrapperComponent || !contentComponent) {
throw new Error("Components are not mounted");
return {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this causes resetTransform to not work

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How exactly? I mean this change should affect anything only at first render time to prevent this component throwing an error in case of a delayed render of a children.

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

Successfully merging this pull request may close these issues.

"Components are not mounted" error if TransformComponent render is delayed/conditional
2 participants