Allow numeric dimensions in Use element, cleanup Svg element.

This commit is contained in:
Mikael Sand
2018-04-04 21:55:03 +03:00
parent 046c7efc04
commit 5e1bb859fc
2 changed files with 7 additions and 9 deletions
+5 -7
View File
@@ -10,6 +10,7 @@ import {
} from "react-native"; } from "react-native";
import extractViewBox from "../lib/extract/extractViewBox"; import extractViewBox from "../lib/extract/extractViewBox";
import { ViewBoxAttributes } from "../lib/attributes"; import { ViewBoxAttributes } from "../lib/attributes";
import { numberProp } from "../lib/props";
/** @namespace NativeModules.RNSVGSvgViewManager */ /** @namespace NativeModules.RNSVGSvgViewManager */
const RNSVGSvgViewManager = NativeModules.RNSVGSvgViewManager; const RNSVGSvgViewManager = NativeModules.RNSVGSvgViewManager;
@@ -27,9 +28,9 @@ class Svg extends Component {
static displayName = "Svg"; static displayName = "Svg";
static propTypes = { static propTypes = {
...ViewPropTypes, ...ViewPropTypes,
opacity: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), opacity: numberProp,
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), width: numberProp,
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), height: numberProp,
// more detail https://svgwg.org/svg2-draft/coords.html#ViewBoxAttribute // more detail https://svgwg.org/svg2-draft/coords.html#ViewBoxAttribute
viewBox: PropTypes.string, viewBox: PropTypes.string,
preserveAspectRatio: PropTypes.string preserveAspectRatio: PropTypes.string
@@ -41,10 +42,7 @@ class Svg extends Component {
constructor() { constructor() {
super(...arguments); super(...arguments);
id++; this.id = ++id;
this.id = id;
//noinspection JSUnusedGlobalSymbols
this.onDataURLCallbacks = [];
} }
measureInWindow = (...args) => { measureInWindow = (...args) => {
this.root.measureInWindow(...args); this.root.measureInWindow(...args);
+2 -2
View File
@@ -46,8 +46,8 @@ export default class extends Shape {
}} }}
{...extractProps(props, this)} {...extractProps(props, this)}
href={href} href={href}
width={props.width} width={props.width.toString()}
height={props.height} height={props.height.toString()}
> >
{props.children} {props.children}
</RNSVGUse> </RNSVGUse>