Closed catamphetamine closed 8 years ago
Interesting. Maybe we should just add a test case to make sure it will work correctly.
I don't know why but the second time I render the whole thing it doesn't output the warning:
renderIntoDocument(
<Provider store={store}>
<ReduxRouter RoutingContext={function(props) { return <div /> }}>
{routes}
</ReduxRouter>
</Provider>
);
I event put it into separate it
tests, still no second warning.
it('only accepts React.Components for "RoutingContext" prop', () => {
const reducer = combineReducers({
router: routerStateReducer
});
const history = createHistory();
const store = reduxReactRouter({
history
})(createStore)(reducer);
store.dispatch(push({ pathname: '/parent/child/123', query: { key: 'value' } }));
// let consoleErrorSpy = sinon.spy(console, 'error');
let tree = renderIntoDocument(
<Provider store={store}>
<ReduxRouter RoutingContext={function(props) { return <div /> }}>
{routes}
</ReduxRouter>
</Provider>
);
renderIntoDocument(
<Provider store={store}>
<ReduxRouter>
{routes}
</ReduxRouter>
</Provider>
);
// assert(consoleErrorSpy.calledOnce, 'console.error must have been called');
// expect(consoleErrorSpy.args[0][0]).to.contain(
// 'Invalid prop `RoutingContext` of type `Function` supplied to `ReduxRouterContext`'
// );
// console.error.restore();
// consoleErrorSpy = sinon.spy(console, 'error');
renderIntoDocument(
<Provider store={store}>
<ReduxRouter RoutingContext={function(props) { return <span /> }}>
{routes}
</ReduxRouter>
</Provider>
);
// assert(consoleErrorSpy.called, 'console.error must have been called in this case too');
// console.error.restore();
});
Ok, here you go. The tests. https://github.com/acdlite/redux-router/pull/267
fixed by #267
republished on npm.
Following https://github.com/acdlite/redux-router/issues/260 , because it is unable to be reopened.
Seems that the fix didn't actually fix the issue. I get it now:
PropTypes.instanceOf(Component)
won't work because it's not an instance of a Component but rather a class extending Component. The only suitable PropType isPropTypes.func
then.