Fix default color and stroke width properties for Geojson component#3972
Merged
christopherdro merged 1 commit intoreact-native-maps:masterfrom Oct 12, 2021
Merged
Fix default color and stroke width properties for Geojson component#3972christopherdro merged 1 commit intoreact-native-maps:masterfrom
christopherdro merged 1 commit intoreact-native-maps:masterfrom
Conversation
- Fixes react-native-maps#3971 - According to React docs, `defaultProps` only takes effect for `undefined` props, **not** `null` props - By returning `null` from `getColor`, it ends up passing a `null` prop down to the native component instead of the `defaultProps` values from `MapPolygon`, `MapPolyline`, etc. - Switching to a simple `return` will return `undefined` from `getColor` and `getStrokeWidth`, which means the default props can take effect - Updated the documentation to: - Specify the actual GeoJSON property names that are being checked - Specify that stroke color and stroke width are only used for polygons and polylines (not just "paths") - Specify that `fillColor` is only relevant for polygons - Add the undocumented `color` property, which appears to be used for Marker/"point" types - With these changes, the default stroke width of 1 and color of #000 seems to be working for my GeoJSON LineString/Polyline
AlissonEnz
approved these changes
Oct 6, 2021
|
Great fix |
christopherdro
approved these changes
Oct 12, 2021
pinpong
pushed a commit
to pinpong/react-native-maps
that referenced
this pull request
Feb 28, 2025
…eact-native-maps#3972) - Fixes react-native-maps#3971 - According to React docs, `defaultProps` only takes effect for `undefined` props, **not** `null` props - By returning `null` from `getColor`, it ends up passing a `null` prop down to the native component instead of the `defaultProps` values from `MapPolygon`, `MapPolyline`, etc. - Switching to a simple `return` will return `undefined` from `getColor` and `getStrokeWidth`, which means the default props can take effect - Updated the documentation to: - Specify the actual GeoJSON property names that are being checked - Specify that stroke color and stroke width are only used for polygons and polylines (not just "paths") - Specify that `fillColor` is only relevant for polygons - Add the undocumented `color` property, which appears to be used for Marker/"point" types - With these changes, the default stroke width of 1 and color of #000 seems to be working for my GeoJSON LineString/Polyline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
defaultPropsonly takes effect forundefinedprops, notnullpropsnullfromgetColor, it ends up passing anullprop down to the native component instead of thedefaultPropsvalues fromMapPolygon,MapPolyline, etc.returnwill returnundefinedfromgetColorandgetStrokeWidth, which means the default props can take effectfillColoris only relevant for polygonscolorproperty, which appears to be used for Marker/"point" typesDoes any other open PR do the same thing?
Not that I know of.
What issue is this PR fixing?
How did you test this PR?
Just manually overwrote my local
node_modulescopy ofGeojson.jswith the changes and verified that the feature displayed as expected.