Created
November 26, 2019 16:04
-
-
Save alexsullivan114/c7e8ce0afdb1d96d84a47212b9dc8e63 to your computer and use it in GitHub Desktop.
JSX Confusion
This file contains 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
const FeatureLayer = ({ id, circular }: { id: string; circular: boolean }) => { | |
if (circular) { | |
return ( | |
<MapboxGL.CircleLayer | |
id={`${id}-circle`} | |
style={{ circleRadius: 500, circleColor: "black" }} | |
/> | |
) | |
} else { | |
return ( | |
<MapboxGL.FillLayer id={`${id}-fill`} style={layerStyles.featureFill} /> | |
) | |
} | |
} | |
// This doesn't work | |
const FillFeature = ({ feature, id, circular }: FillFeatureProps) => { | |
return ( | |
<MapboxGL.ShapeSource id={id} shape={feature}> | |
<FeatureLayer id={id} circular={circular} /> | |
</MapboxGL.ShapeSource> | |
) | |
} | |
// This works | |
const FillFeature = ({ feature, id, circular }: FillFeatureProps) => { | |
return ( | |
<MapboxGL.ShapeSource id={id} shape={feature}> | |
{circular ? ( | |
<MapboxGL.CircleLayer | |
id={`${id}-circle`} | |
style={{ circleRadius: 50, circleColor: "black" }} | |
/> | |
) : ( | |
<MapboxGL.FillLayer id={`${id}-fill`} style={layerStyles.featureFill} /> | |
)} | |
</MapboxGL.ShapeSource> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment