question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding prev history to locationState on initial load?

See original GitHub issue

I’d like to push some history (e.g. pathname) to the prev object on initial load of the page.

Is it possible to do this without using the Rudy-History package or do I need the createHistory function that returns an object in some proper form to connectRoutes?

Thanks for shedding a little light on this, it seems weird to require another package when what it looks like I’m trying to do is simply:

location: {
  ...location,
  prev: {
    ...location.prev,
    pathname: 'newpath'
  }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
hedgepigdanielcommented, Jul 19, 2019

I haven’t tried it, but my impression from reading the code is that this is supported in Rudy by using the history reset function

https://github.com/respond-framework/rudy/blob/3c184800682bbfa5adaecb7e8aef3657cb0ff9f6/packages/rudy/src/middleware/transformAction/utils/formatAction.js#L30

https://github.com/respond-framework/rudy/blob/3c184800682bbfa5adaecb7e8aef3657cb0ff9f6/packages/rudy/src/actions/history.js#L34

Basically you import reset and it will create a redux action that resets the entire history stack to whatever you want

0reactions
ml242commented, Jul 26, 2019

It seems like no matter what i try with regard to pushing/replacing/resetting state on initial page load, i dont get the back button functionality (it’s grayed out).

But if I browse to a page and then back, the new history has been inserted and takes the correct number of button presses (so one more will go to the new Page / button is active).

Do you think this is a chrome issue and not a router issue?

Thanks again

edit: doesn’t seem related to lib so closing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I clear location.state in react-router on page reload?
If you're using react hooks, you can use window.history directly to clear the state without triggering a rerender. This is better than using...
Read more >
Using React with the History API - Pluralsight
React Router has a useHistory hook that provides a history interface that we can easily use for routing. Add buttons to these pages...
Read more >
Programmatically Navigate Using React Router - Stack Abuse
In this guide, learn how to create routes, programmatically navigate, send and receive data using React Router in JavaScript, with practical ...
Read more >
React Router - Using Location State for Custom UI Navigation
React Router - Using Location State for Custom UI Navigation ... Send us to the previous page history.push(redirectUrl) // i.e. "/posts".
Read more >
History API - MDN Web Docs - Mozilla
Chrome Edge Firefox History Full support. Chrome1. Toggle history Full support. Edge12. Toggle history Full sup... back Full support. Chrome1. Toggle history Full support. Edge12....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found