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

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

Closed
pecoram opened this issue May 7, 2024 · 4 comments · Fixed by #417
Closed

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

pecoram opened this issue May 7, 2024 · 4 comments · Fixed by #417

Comments

@pecoram
Copy link

pecoram commented May 7, 2024

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 }}
  1. On newpage page
     const location = useLocation();
     console.log(location.state.myState)
  1. location.state is undefined

Expected behavior

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

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: 0.13.3

Additional context

In v0.13.2 it works

@oedotme
Copy link
Contributor

oedotme commented May 8, 2024

@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
Copy link
Author

pecoram commented May 8, 2024

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

here another example with last version
here with previous version

@pecoram pecoram changed the title location.state undefined on v0.13.2 location.state undefined on v0.13.3 May 9, 2024
@pecoram pecoram changed the title location.state undefined on v0.13.3 location.state undefined with HashRouter on v0.13.3 May 9, 2024
@oedotme
Copy link
Contributor

oedotme commented May 9, 2024

@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
Copy link
Author

pecoram commented May 9, 2024

In the meantime, I have corrected the two links

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

Successfully merging a pull request may close this issue.

2 participants