solidjs / solid-router

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

location.state undefined with HashRouter on v0.13.3 #416

Closed pecoram closed 1 month ago

pecoram commented 2 months ago

Describe the bug

With version 0.13.3 of solid-router the set location.state is undefined using HashRouting .

Your Example Website or App

https://codesandbox.io/p/sandbox/solid-router-state-issue-nfp7dg

Steps to Reproduce the Bug or Issue

1) On pageone page

    const navigate = useNavigate();
    navigagate("newpage", { state: { myState: true }}

2) On newpage page

     const location = useLocation();
     console.log(location.state.myState)

3) location.state is undefined

Expected behavior

I expected location.state is { myState: true } but got undefined.

Screenshots or Videos

No response

Platform

Additional context

In v0.13.2 it works

oedotme commented 2 months ago

@pecoram Here's a StackBlitz example with location.state changes as expected.

Could you please share an example with your usage if your issue persist? Thanks

pecoram commented 2 months ago

your example is perfect! try with HashRouter.. Sorry I forgot to specify it

here another example with last version here with previous version

oedotme commented 2 months ago

@pecoram For some reason, none of the CodeSandbox links worked for me.

I've found that this issue happens only with replace: false (the default option) and added a potential fix for that.

pecoram commented 2 months ago

In the meantime, I have corrected the two links