Open xdave opened 7 years ago
Yeah, really it should allow history
as a prop. I kind of meant to do that but never got to it. Not sure when I'll get to that (actually on vacation now). If love a PR for that if you want to give it a try!
Sure, I'll take a look this evening.
Ug, there's lots of API changes between those history versions. I'm a bit fuzzy as to what the History component is doing and how it works.
history 2.0.1 => history 4.6.1:
101 files changed, 7582 insertions(+), 4147 deletions(-)
@xdave Yeah, it looks like they got rid of listenBefore
. This affects the History
component's ability to cancel routing. The History
component allows setting the route via the url
prop, and it also allows listening to external route changes through the onChange
prop. When the onChange
callback is called, the same url
is expected to be fed back through the prop. Otherwise, it's assumed that the route was cancelled. It looks like history.block
is the new way to cancel transitions, but it doesn't support a callback for cancellation, so rather than dynamically creating a callback, we'll have to check for cancellation right after onChange is called. There's one test that validates the cancellation behavior, so we'd just have to make sure that still passes.
I have apps that only use the hash for route changes (using react-router). Usually, I can switch between them by importing a different history implementation.
For example, instead of:
(it appears you are using the old history version 2.0.1)
I use:
(using history@4.6.1 https://github.com/ReactTraining/history)