history icon indicating copy to clipboard operation
history copied to clipboard

Why `history.length` is gone?

Open baeharam opened this issue 2 years ago • 7 comments

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.

baeharam avatar Aug 11 '22 07:08 baeharam

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

Nantris avatar Aug 26 '22 20:08 Nantris

Use window.history.length

janyin avatar Sep 13 '22 12:09 janyin

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

Nantris avatar Sep 13 '22 19:09 Nantris

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.

baeharam avatar Sep 17 '22 07:09 baeharam

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

KingAmo avatar Aug 01 '23 03:08 KingAmo

Does anyone know how to know history.length?

rumi-ju avatar Feb 06 '24 00:02 rumi-ju

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.

Nantris avatar Feb 06 '24 19:02 Nantris