solidjs / solid-router

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

[Bug?]: Parameters don't get filled in on the loader in the routes #381

Closed gabrielmfern closed 5 months ago

gabrielmfern commented 7 months ago

Duplicates

Latest version

Current behavior 😯

When trying to receive the parameters from the route inside of the load function for the route export of a route the parameters come out as empty. Not sure if this was a @solidjs/router issue or a start issue, so I'm assuming this is a start issue.

This can clearly be seen by just running the hacker-news example and opening up one of the stories.

Expected behavior 🤔

That the parameters properly are passed in the load function defined in the export const route = { ... } statement.

Steps to reproduce 🕹

Steps:

  1. Add a console.log of the params inside of the load function here https://github.com/solidjs/solid-start/blob/b0428cb03e58dc3e98ec82c8193fd13709a1fb94/examples/hackernews/src/routes/stories/%5Bid%5D.tsx#L6-L10
  2. Open the browser at http://localhost:3000/stories/39403189
  3. Verify in the server logs that the parameters are just {} instead of the expected JSON { "id": "39403189" }

Context 🔦

I'm just trying to cache something the same as the hacker-news example does it, but in my situation it going on like this made it crash as my website wasn't ready to fetch on the client. I understand this is not how I should probably go about implementing this, and I am adding the proper code to handle the fetching on the client, but the load function should come with the proper parameters and this is still a bug.

Your environment 🌎

Using the latest version of both the router and start.

Running this on Linux with Node 20.10.0

brenelz commented 7 months ago

I just tested it out and it seems to work properly logging out the id in the load function

gabrielmfern commented 7 months ago

I just tested it out and it seems to work properly logging out the id in the load function

Weird, would there be any reason for this issue possibly being platform specific?

brenelz commented 7 months ago

I tested on Mac so maybe its a Linux thing?

ryansolid commented 7 months ago

I'm pretty sure the id is there but the logging is missing it because of the way the getter is defined.. lets see if there is something we can do about this in the router.

ryansolid commented 7 months ago

Yeah I think this is just platform to platform. We added ownKeys and set descriptors to configurable and enumerable. I'm not sure there is much more to be done. Just how proxies console.log I guess.