-
Notifications
You must be signed in to change notification settings - Fork 7
Prevent Presence component to crash if mountedStates does not contain the provided element #11
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
Conversation
…in the provided element
Could you replicate the situation where that happens? |
well, the code probably tries to protect against the situation when Anyways, the situation where that actually happens is hard to track. For me it happens when a specific route in solid-router tries to render a |
I don't think that's true. Although I don't doubt that there might be some bugs visible when using router with this library, as it means that suspense boundaries and transitions are present. Which may cause the "Somehow the So if you patch it and that works, that's great, but I would still love to find out a reason why that is. |
Thanks for the feedback. The production code of the library has a different shape, like in (mountedStates.get(el)?.getOptions()).exit ? el.addEventListener("motioncomplete", done) : done(); The parens, that where inserted in order to make the type cast, are still present in the transpiled code, and that is what throws:
The code that throws in my case is a The situation that throws is when I initially load the page with a route where the active case of the here is the component that throws: https://github.com/trivial-space/website/blob/3409bee4956dc0532d92f3a96820421d75043028/src/Work.tsx#L151 I hope this helps. Unfortunately I am not that firm with the internals of motion one or solid js to be able to create a minified example in short time... |
it's the parenthesis used for typecasting... |
your code looks fine so I'm not sure why onExit would be called at a wrong time |
This should remove the parenthesis used for typecasting, that was causing an issue reported in #11
I had the situation where
mountedStates.get(el)
was actually undefined. That throws and breaks the app since the provided guard is not sufficient to prevent the access toundefined.exit
.Please consider adding the extra optional chaining operator to prevent such crashes.