Skip to content
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

Fix default color and stroke width properties for Geojson component #3972

Merged
merged 1 commit into from
Oct 12, 2021

Conversation

aardvarkk
Copy link
Contributor

@aardvarkk aardvarkk commented Sep 29, 2021

  • 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

Does 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_modules copy of Geojson.js with the changes and verified that the feature displayed as expected.

- 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
Copy link

Great fix

@christopherdro christopherdro merged commit fdd1eea into react-native-maps:master Oct 12, 2021
borjomemost pushed a commit to borjomemost/react-native-maps that referenced this pull request May 6, 2022
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants