-
Notifications
You must be signed in to change notification settings - Fork 855
Skip falsy markers #204
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
Skip falsy markers #204
Conversation
@@ -229,6 +229,7 @@ export default class GoogleMapMarkers extends Component { | |||
this.dimesionsCache_ = {}; | |||
|
|||
const markers = React.Children.map(this.state.children, (child, childIndex) => { | |||
if (!child) return null; |
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.
why null? why not undefined or why not a filter like util
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've commented on the issue as well:
I've returned null if child is falsy. The resulting array is passed to react so no need to filter out them after map.
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.
Also, I can see this library being used with big amounts of markers, so minimising the amount of steps of intermediate array construction (with .map
and .filter
), might be a good thing.
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 don't like null
s ;-) the same result we will get with undefined
.
So the question was about does null
here has any advantage or hidden sense over undefined
.
Having ES6 using null
in any chain like env prevents me to use arguments defaults in the future, so I prefer not to use null
at all.
So please change null on undefined ;-)
I've changed References: Early react didn't even have proper validation for undefined:
|
Thank you! |
npm 0.16.2 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Fixes #203