Closed as not planned
Closed as not planned
Description
I'm using React Router as a...
library
Reproduction
import { Link } from 'react-router'
<div>
<Link to="/cart">Go to Cart</Link>
</div>
Sorry for not providing more but it's not necessary, really. The <Link />
component doesn't seem to have the same check as React Router hooks, resulting in a degrading DX.
System Info
I believe this is irrelevant.
Used Package Manager
npm
Expected Behavior
I expect this unintentionally incorrect usage to throw the same error as I get when using React Router hooks without the <Router />
context:
Error: <Link> may be used only in the context of a <Router> component.
This will be a more meaningful error message and will help me figure out what I'm doing wrong, as opposed to the internal "cannot read from context because context doesn't exist", which doesn't tell me much.
Actual Behavior
The following, user-unfriendly error is being thrown:
Cannot destructure property 'basename' of 'React10.useContext(...)' as it is null.
I know this error has been raised before in #11237 and #10867, none of which were actually solved for developers also due to this error being semi-cryptic.