-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: set default strokeWidth to 1 on android (#2269)
# Summary According to [MDN Docs](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-width), when `strokeWidth` is not provided, the default value should be set to `1`. On android, when we update the `strokeWidth` prop to `undefined` it was mistakenly converted to `0` by `SVGLength`. Fixes #2266 ## Test Plan Test available in `TestsExample/Test2266` ### What are the steps to reproduce (after prerequisites)? * Run `TestsExample` app * Replace `ColorTest` with `Test2266` in `App.js`
- Loading branch information
Showing
3 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, {useState} from 'react'; | ||
import {Button, View} from 'react-native'; | ||
import {Circle, Svg} from 'react-native-svg'; | ||
|
||
export default () => { | ||
const [strokeWidth, setStrokeWidth] = useState<undefined | number>(undefined); | ||
return ( | ||
<View> | ||
<Svg viewBox="0 0 30 10" width={400} height={200}> | ||
<Circle cx="5" cy="5" r="3" stroke="green" /> | ||
<Circle cx="15" cy="5" r="3" stroke="green" strokeWidth="3" /> | ||
<Circle cx="25" cy="5" r="3" stroke="green" strokeWidth="2%" /> | ||
</Svg> | ||
<Button | ||
title="stroke: undefined" | ||
onPress={() => setStrokeWidth(undefined)} | ||
/> | ||
<Button title="stroke: 0" onPress={() => setStrokeWidth(0)} /> | ||
<Button title="stroke: 1" onPress={() => setStrokeWidth(1)} /> | ||
<Button title="stroke: 2" onPress={() => setStrokeWidth(2)} /> | ||
<Svg viewBox="0 0 30 10" width={400} height={200}> | ||
<Circle cx="5" cy="5" r="3" stroke="green" strokeWidth={strokeWidth} /> | ||
<Circle cx="10" cy="5" r="3" stroke="green" /> | ||
</Svg> | ||
</View> | ||
); | ||
}; |
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