remix-run / history

Manage session history with JavaScript
MIT License
8.29k stars 961 forks source link

Why `history.length` is gone? #960

Open baeharam opened 2 years ago

baeharam commented 2 years ago

I'm migrating from react-router-domv5 to v6, and encountered that history.length is no longer supported in history v5. In this situation, I have several questions.

1) Why history.length is gone? Is there some contexts related to about this? 2) How can I replace this feature? (= substitution..?)

I looked for lots of channels(SO, RRD github issue, history github issue, googling etc...) but couldn't find out the reason and solution. Thanks for your reading.

Nantris commented 2 years ago

Doesn't seem to be mentioned in the changelog, but yeah that's surprising.

janyin commented 1 year ago

Use window.history.length

Nantris commented 1 year ago

Thanks for the tip but that won't help when the chosen history type is MemoryHistory.

baeharam commented 1 year ago

I think this change should be mentioned in docs. Additionally, if you use unstable_HistoryRouter in version 6.3, you can use window.history.length probably.

KingAmo commented 1 year ago

how to get history.length ? react-router-dom: 6.14.2 and createBrowserRouter

rumi-ju commented 7 months ago

Does anyone know how to know history.length?

Nantris commented 7 months ago

There's been a PR open for this for two years. It's adds 4 lines of code and reverts an undocumented change. My perception is that the maintainers just don't care. You're on your own. I waited hopefully for a long time.

I won't ever use this library for future projects.