Closed catamphetamine closed 8 years ago
@Scarysize Ok, then I updated the Pull Request to include the fix as well.
The clue why it failed before is in the test code: PropType.extends(Component)
(if it existed) and PropType.instanceOf(Component)
are different things.
Nice. Should we add an additional test for stateless components?
@Scarysize Added a test for a stateless component
@halt-hammerzeit Just some minor issues. Fix these and I'm happy to merge. 👌
@Scarysize did some splitting and variable extraction
Nice work 👍
If @mjrussell has given it a quick overlook I will merge this.
I saw the original issue, but Im not sure why RoutingContext isn't allowed to be a Component
or a function. Is there a reason why we are explicitly preventing people from doing this?
@mjrussell
not sure why RoutingContext isn't allowed to be a Component or a function
It wasn't allowed to be a Component or a function, and it is allowed that in this PR. Just to clarify things.
Sorry I should have been more clear. It looks like you are restricting it to just functions, shouldn't the proptype be
PropTypes.oneOfType[PropTypes.func, PropTypes.element].isRequired
Or is there currently no warning if you pass a React class (non instantiated like your test).
@mjrussell There's no PropType
for React components. The code you wrote is invalid.
Was on my phone so I missed a paren.
PropTypes.oneOfType([PropTypes.func, PropTypes.element]).isRequired
Is definitely valid. Check out the docs - https://facebook.github.io/react/docs/reusable-components.html
It might not be necessary to add the element option but I'll write a quick test
@mjrussell It is valid syntactically but is wrong conceptually. Refer to React docs to read more about what is an "Element".
Did a sanity check with both React.createClass
and extending React.Component
. Looks good, I forgot that the element is for rendered instances, not react component definitions.
This looks good to me, I spotted a minor test typo I'll point out in the code
@mjrussell Thanks for the feeback!
@halt-hammerzeit The warning which will be printed during tests:
Warning: Failed propType: Invalid prop `RoutingContext` of type `object` supplied to `ReduxRouterContext`, expected `function`. Check the render method of `Connect(ReduxRouterContext)`.
Comes from the should not accept non-React-components for "RoutingContext" prop of ReduxRouter
test, am I right?
@Scarysize Yes
Okay, just needed to be sure.
Cool, thank you! I hope, I will come around to get this fixed. Though I have no clue why this fails yet.