FormidableLabs / redux-little-router

A tiny router for Redux that lets the URL do the talking.
MIT License
1.04k stars 114 forks source link

Crashing inside this project's code/deps #201

Closed haf closed 7 years ago

haf commented 7 years ago
Uncaught TypeError: Cannot read property 'search' of undefined
    at exports.default (eval at ./node_modules/redux-little-router/lib/util/normalize-href.js (app.js:9170), <anonymous>:31:20)
    at Link (eval at ./node_modules/redux-little-router/lib/components/link.js (app.js:9042), <anonymous>:96:42)
    at eval (eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js (app.js:6462), <anonymous>:306:16)
    at measureLifeCyclePerf (eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js (app.js:6462), <anonymous>:75:12)
    at ReactCompositeComponentWrapper._constructComponentWithoutOwner (eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js (app.js:6462), <anonymous>:305:14)

The stack trace does not give me anything about what component it is that crashing either.

When given code like this:

<Link className='nav-link' to='/legal/terms-of-use'>...
tptee commented 7 years ago

Are you wrapping your top-level component in <Provider> from react-redux? Looks like the location state isn't coming down

haf commented 7 years ago

Yes, I am, this comes from having a to rather than a href in the link. I don't think it's a question; it's a bug report.

tptee commented 7 years ago

Oh I see it now–href is a mandatory prop and a non-nullable type in the Flow annotations. The to prop is react-router's version of href. Switch 'em out and you should be fine 😃

haf commented 7 years ago

@tptee Yes, that's true. I guess what I filed the bug because the crash is not from defensive programming at the edge of the library, and libraries should guard their input with such facilities.