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

Use history replace when appropriate #51

Open
kj800x opened this issue Oct 16, 2023 · 1 comment
Open

Use history replace when appropriate #51

kj800x opened this issue Oct 16, 2023 · 1 comment

Comments

@kj800x
Copy link

kj800x commented Oct 16, 2023

It may be better to use history.replace instead unless the page has changed semantically, otherwise the history will be filled with unexpected entries. In general, it's good to use push whenever the page should "feel like" a different page, and replace whenever the page "feels like" the same page just with some updates.

history.push(window.location.pathname + "?amount="+this.state.amount + "&timelimit=" + Math.round(Math.pow(1.8,this.state.limitfactor)) + "&ingredientsToBuild="+Object.keys(this.state.ingredientsToBuild).join(","));

https://github.com/remix-run/history/blob/3e9dab413f4eda8d6bce565388c5ddb7aeff9f7e/docs/navigation.md

@schollz
Copy link
Owner

schollz commented Oct 16, 2023

Happy to accept a PR!

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

No branches or pull requests

2 participants