acdlite / redux-router

Redux bindings for React Router – keep your router state inside your Redux store
MIT License
2.3k stars 200 forks source link

Invalid prop `RoutingContext` supplied to `ReduxRouterContext`, expected a single ReactElement. #260

Closed catamphetamine closed 8 years ago

catamphetamine commented 8 years ago

But <RoutingContext/> is a Component, not an Element https://github.com/reactjs/react-router/blob/master/modules/RoutingContext.js I guess you should fix the propTypes https://github.com/acdlite/redux-router/blob/master/src/ReduxRouter.js#L106

  static propTypes = {
    location: PropTypes.object,
    RoutingContext: PropTypes.element,
  }
catamphetamine commented 8 years ago

Since there's no PropTypes.component I guess that could be PropTypes.any.

Scarysize commented 8 years ago

Please provide us with a code snippet/gist, so we can recreate your error.

AFAIK React.PropTypes.component was a thing until React 0.12.0, then it has been renamed to element. As there weren't any issues with this so far, there might just be an error on your side.

catamphetamine commented 8 years ago

@Scarysize Well, try to do this simple thing and you'll get the error:

import { RouterContext } from 'react-router'
<ReduxRouter RouterContext={RouterContext} />

As there weren't any issues with this so far, there might just be an error on your side.

As there weren't any issues with this so far, it means that no one used that feature.

Scarysize commented 8 years ago

Hm. I would like to be more specific than any. But instanceOf or componentName seem to be a bit too restrictive. What's your opinion?

catamphetamine commented 8 years ago

@Scarysize I googled yesterday for "React PropTypes Component" and found no really useful links except for a lot of static noise due to this particular word combination ambiguity. That could be, say, anyOf(instanceOf(Component), functionOf(props, context(?))). A react guru would know. Should we summon someone from facebook? Let's try @gaearon

catamphetamine commented 8 years ago

I would go with

React.PropTypes.oneOfType([
    React.PropTypes.instanceOf(React.Component),
    React.PropTypes.func
])
Scarysize commented 8 years ago

Will fix this today and republish :)