New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Isvalidelement #24
Isvalidelement #24
Conversation
src/index.js
Outdated
}, | ||
|
||
/** | ||
* @param {RenderElement} element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{*} element
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method can take any type of argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get it.
src/index.js
Outdated
*/ | ||
isValidElement: function (element) { | ||
return element === null || | ||
(typeof element === 'object' && typeof element.type !== 'undefined' && typeof element.props === 'object'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- we can add small function
isObject
, to make code more readable element.hasOwnProperty('type')
what do you think about that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- isObject equal typeof object == 'object'?
- That's good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- yep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i write it now
return object !== null && typeof object === 'object' && !Array.isArray(object);
src/index.js
Outdated
|
||
/** | ||
* @param {RenderElement} element | ||
* @returns {boolean} isValid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be Boolean
(in Title case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I think about it like a primitive, but it's a Boolean so that's right.
…replace type check with isObject in isValiElement, replace not undefined check with hasOwnProperty type in isValidElement
Fix change requests. Please review ._. |
thanks for contribution 🎉 |
Thanks for release 🙆 |
#21 implement isValidElement