fix isReactComponent returning true for blank input - #78
Conversation
akxcv
left a comment
There was a problem hiding this comment.
Hello and thank you for this pull request! There are a couple of questions I have about the code, but they should be easy enough to resolve.
| @@ -1,4 +1,5 @@ | |||
| export default function isReactComponent (component) { | |||
| if (!component) return false | |||
There was a problem hiding this comment.
Perhaps it would be better to write this as
if (component === undefined || component === null || component === false)For example, I'm not sure if this is correct behaviour for cases when component is '' or 0.
There was a problem hiding this comment.
Hey, thanks for your reply. I think '' and 0 shouldn't be considered valid React components either so it might be ok to leave it as is?
There was a problem hiding this comment.
The thing is, it works both ways because the React wrapper is also using this function. Actually, with your fix it's the React side that will suffer from similar errors. Instead, we should probably just leave "falsy" components as they were. Shouldn't be difficult to do, do you think you can find the time to implement this?
There was a problem hiding this comment.
To be clear, I meant not wrapping falsy components whatsoever.
isReactComponentreturnedtruefor blank inputs (e.g.undefined), which could produce confusing error messages. E.g. from Vue if you hadcomponents: {MyComponent: undefined}(could be undefined because of e.g. a failing import) it would display a Vuera ReactWrapper error instead of the normal Vue "[Vue warn]: Unknown custom element" error.