solidjs / solid-router

A universal router for Solid inspired by Ember and React Router
MIT License
1.13k stars 143 forks source link

Location signal is triggered on navigation before integration getter #297

Closed adjourn closed 7 months ago

adjourn commented 1 year ago

Describe the bug

Reference signal value is set in navigateFromRoute: https://github.com/solidjs/solid-router/blob/79a2b577564772b8248aa75c5300dcb61e650e59/src/routing.ts#L395 Location signal is subscribed to it which means that it triggers all useLocation, etc that subscribe to location, including route selection/rendering. Issue manifests when custom router integration is used, its getter function runs AFTER setting reference.

As far as I understand (correct me if that's not the case), one of the points of integration getter is to return any location based on business logic that might not correlate to window.location or other state of the world. But current flow is like this:

Your Example Website or App

https://codesandbox.io/s/solid-app-router-example-forked-25ysls?file=/Index.js

Steps to Reproduce the Bug or Issue

  1. Go to Home (/) if not already there
  2. Open dev console logs (clear it as well)
  3. Click on any of the Post X (modal) links

You should see in console logs:

Expected behavior

I'd expect integration getter to be the source of truth without any side-effects nor extra work.

Screenshots or Videos

No response

Platform

Additional context

No response

adjourn commented 7 months ago

Closing since there's no more source on Router and I have to find a new way to do my dark routing magic..