Skip to content

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

Merged
merged 1 commit into from
Jul 24, 2016
Merged

Skip falsy markers #204

merged 1 commit into from
Jul 24, 2016

Conversation

shark0der
Copy link
Contributor

Fixes #203

@@ -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;
Copy link
Collaborator

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

Copy link
Contributor Author

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.

Copy link

@dapetcu21 dapetcu21 Jul 24, 2016

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like nulls ;-) 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 ;-)

@shark0der
Copy link
Contributor Author

I've changed null to undefined as per request, however, you should keep in mind that null is generally more acceptable than undefined.

References:

Early react didn't even have proper validation for undefined:
facebook/react#1647

Therefore passing undefined may actually change behavior of underlying classes in confusing ways.

facebook/react#1668 (comment)

@istarkov
Copy link
Collaborator

Thank you!
(IMO both null and undefined should gone from all languages ;-))

@istarkov istarkov merged commit ef1689e into google-map-react:master Jul 24, 2016
@istarkov
Copy link
Collaborator

npm 0.16.2

@lock
Copy link

lock bot commented Dec 1, 2019

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.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Conditionally rendering marker
3 participants