CharlesStover/use-react-router

Provide a more informative error message for react-router@4.3 or earlier.

theduke opened this issue · 4 comments

With the 16.8 alpha, I'm getting the following error when using const router = useReactRouter(); in a component:

TypeError: Context is undefined

react-router is version 4.3.1.

(I've made sure that only 16.8 is present in my yarn.lock)

from the README - You must be using react-router v4.4.0 or greater.

First thing we run into too.
Maybe having the error say you should probably upgrade?

@sahanay I did a similar thing with packages that required React Hooks by saying "upgrade to 16.7," but then Facebook published 16.7 (non-alpha) without including hooks. Users then complained that they had upgraded to 16.7 but were still getting the error saying to upgrade. Since the exposure of Context appears to be alpha in react-router, much like Hooks in React, I am afraid that by publishing a version number in the package itself will lead to a similar problem. react-router@4.x may come out and suddenly Context is no longer exposed or exposed under a different variable name, and users will get an unhelpful error asking them to upgrade, despite them already using @latest.

It's kind of lose-lose. I am open to a more informative error message, but I am at a loss for what the error message should be.

Closing this now that react-router has officialized its context-supported release as 5.0+.