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

Immediately schedule destruction of view.element on unmount #833

Conversation

KentShikama
Copy link

@KentShikama KentShikama commented May 6, 2022

Just illustrating the root of the problem for pqina/react-filepond#207. Not a merge-able fix but a fix nonetheless. Feel free to close upon read.

With StrictMode, React renders each component twice: specifically mount, unmount, mount. The crux of the issue is that exports.fire('destroy', view.element) is not scheduled to execute the underlying function before the second component mount is called. This means that filepond is trying to manipulate already manipulated DOM elements and fails.

@rikschennink
Copy link
Collaborator

Hmm I had no idea, is there any way to info the first mount?

@KentShikama
Copy link
Author

@rikschennink I'm not sure I follow. Are you saying you want to detect the first mount and skip it? I believe the idea behind StrictMode is that it is trying to test that the component properly unmounts, so that wouldn't be recommended but I'm also not sure how off the top of my head.

If there was only a way to directly call exports.destroy(view.element) instead of exports.fire('destroy', view.element); which is basically what I did in this PR (just in-lining the function), then it just works. Unfortunately if I do that instead of in-lining the function, it goes into an infinite loop, which is probably why you did the indirection in the first place.

@rikschennink
Copy link
Collaborator

@KentShikama indeed meant skip, I think autocorrect got the best of me ;)

I'm looking into it now, thanks!

@rikschennink
Copy link
Collaborator

Should be fixed in 7.1.2, will close

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.

2 participants