history icon indicating copy to clipboard operation
history copied to clipboard

Restore entries attribute in MemoryHistory interface

Open Donorlin opened this issue 4 years ago • 17 comments

Would feature fix this https://github.com/remix-run/history/issues/828

This PR gives back the feature of MemoryHistory.entries which was available in version 4

Many people are dependent on this feature, mainly because it gives more control over memory history itself.

For example, we are running SPA in the SSR (company historical reasons). This means the SPA state is lost whenever a site is reloaded. In version history@4 we are able to save entries from the history object and pass it to initialEntries of the MemoryRouter to seed it back to its previous state (controlled behavior).

In react-router@6 we are still able to access the MemoryHistory object with UNSAFE_NavigationContext, but not its entries. So we are not able to implement a controlled MemoryRouter.

If it was intentional to remove entries for API reasons, close this PR.

Thank you for your response.

Donorlin avatar Feb 15 '22 10:02 Donorlin

@mjackson could we get some clarity on this? We rely on being able to access history.entries and I know we're not alone from reading #828.

Is there some reason for removing this? Can we approve this PR to add it back? There was no indication this interface was going to be removed and so no reason people would have been hesitant to rely on it - but now we're locked in the past on version 4.x unless either:

  • A: This PR is merged
  • B: We branch history and thereby lose access to future updates without extensive work

Nantris avatar Mar 10 '22 22:03 Nantris

It's also not mentioned as something that was removed, as far as I can tell:

  • https://github.com/remix-run/history/pull/751
  • https://github.com/remix-run/history/releases/tag/v5.0.0

If there's no hard blockers here, I really hope we can get this merged.

Nantris avatar Mar 10 '22 23:03 Nantris

Could we get a reply on this, even if the answer is no to merging? We need clarity on this.

@mjackson

Nantris avatar Mar 15 '22 18:03 Nantris

Could we just get a comment on why it was removed? Please?

It would be awful to go through the work of forking this library to expose entries just to find out there's some good reason it's not exposed anymore. As far as I can tell, it was just removed without mention or reason, but I really don't want to stake hours of time on that and be wrong.

Nantris avatar Mar 30 '22 20:03 Nantris

@chaance sorry to tag you, but I hoped maybe you could provide clarity here as substantial recent contributor.

Nantris avatar Mar 30 '22 20:03 Nantris

Can anyone provide clarity on this? Why not merge this PR?

Nantris avatar Apr 21 '22 19:04 Nantris

@Slapbox We've been busy with other priorities, and Michael has to review/approve API changes. These things sometimes take time. If you can't wait, there's always patch-package.

chaance avatar Apr 22 '22 03:04 chaance

Friendly bump.

Nantris avatar Jul 14 '22 23:07 Nantris

Friendly bump. I'd love to get our project up to date and using the latest react-router, but this is a blocker for us and the PR is ultra-minimalist. I hope it can be approved soon.

Nantris avatar Aug 04 '22 23:08 Nantris

Friendly bump. We remain hesitant to use patch-package in case there's some reason that the entries property was removed from MemoryHistory, although that seems unlikely since it's not in the patch notes.

Nantris avatar Aug 26 '22 20:08 Nantris

Bump

JarekToro avatar Nov 22 '22 18:11 JarekToro

I've given up hope on React Router at this point.

Nantris avatar Nov 22 '22 23:11 Nantris

It looks like this package is not even used by react-router anymore. Pardon me if I am wrong. I am using only github for browsing router packages. All history implementation is now here @remix-run/router and createMemoryRouter is here packages/router/history.ts#L214. Sadly still no entries are exported even though it is more or less the same implementation.

Later today, maybe tommorow, I will recreate this PR for missing entries. Wish us luck.

Donorlin avatar Nov 28 '22 12:11 Donorlin

looks like there already was a PR with this change https://github.com/remix-run/react-router/pull/10499 but got closed.

Apparently this is viewed as a new feature and it should go through their Open Development Process.

Please make some polite noice at this open discussion for this "new" feature https://github.com/remix-run/react-router/discussions/9853

Donorlin avatar Jul 31 '23 13:07 Donorlin