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

$parentBase with null value causes error in segmentize function #43

Open
LonelyVikingMichael opened this issue Sep 6, 2021 · 8 comments

Comments

@LonelyVikingMichael
Copy link

Describe the bug
The screenshot below shows that join() is being passed pathFragments of null and "" respectively in paths.js. This ultimately leads to a TypeError: str is null in the stripSlashes() function. I can see from the stack trace that $parentBase is the null value in question in Route.svelte.

To Reproduce
Difficult, my codebase is a bit involved at this point. I have two <a> elements on a navbar with use:link attributes. Normally, they switch between pages/views perfectly.
One of my pages renders child component forms conditionally, based on some on:click logic to mount/destroy the child components. These children in no way interact with routing. This error only occurs if any of the child components forms are loaded and I select the other <a> on my navbar.

Screenshots
image
Full stack trace
image

Desktop (please complete the following information):

  • OS: Linux
  • Browser: Firefox
  • Version: 91.0.2

Please let me know if you require any additional info, I'll try to put together a minimal example and reproduce in a REPL
Thanks for your work, I really enjoy using this library and the examples in the docs helped a lot.

@LonelyVikingMichael
Copy link
Author

Looks like this is related somehow to transition promises. After removing the transition:fade attributes from the child components, the routing issue is resolved.

How can I work around this?

@leddt
Copy link

leddt commented Oct 3, 2021

I encountered the same issue. Adding |local to all my transitions worked for me (ie: transition:fade|local)

@pnodseth
Copy link

Thanks @leddt, that solution worked for me as well.

@LonelyVikingMichael
Copy link
Author

I encountered the same issue. Adding |local to all my transitions worked for me (ie: transition:fade|local)

This solved it for me as well, thank you.

@mefechoel - this might be worth a mention in the docs?

@visma-sorinbroscaru
Copy link

+1 with last comment, should be mentioned in the docs.

@anonymoose
Copy link

I'm not explicitly specifying any transitions anywhere. Just taking the defaults. Where would you recommend putting the transition:fade|local?

@visma-sorinbroscaru
Copy link

I'm not explicitly specifying any transitions anywhere. Just taking the defaults. Where would you recommend putting the transition:fade|local?

Could it be used inside a 3rd party library you use? I had a nested alert component that had a fade on it, but it was created in an external library so for me it was not obvious at first glance where the transition was placed.

@anonymoose
Copy link

Ultimately I was misusing nested and/or relative paths in routes. After making all routes fully qualified all over the app my problems stopped happening.

Started with this:

<Route path="users/*">
  <Route path="edit/:id" let:params>
    <EditUser id={params.id} />
  </Route>
</Route>

The outer route was relative, which I didn't fully understand. So depending on where I was in the app it would either render correctly or throw the above exception. The exception took me in the wrong direction when the fix was just route related.

Changed all my routes to this:

<Route path="/users/edit/:id" let:params>
  <EditUser id={params.id} />
</Route>

It's more explicit and, given the size of my app, easily manageable.

If the library handled the exception in a more obvious way it would have been helpful, but ultimately this was my fault.

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

No branches or pull requests

5 participants