From 5e1bb859fc281d89feac37dcc3459fcd078e0f91 Mon Sep 17 00:00:00 2001 From: Mikael Sand Date: Wed, 4 Apr 2018 21:55:03 +0300 Subject: [PATCH] Allow numeric dimensions in Use element, cleanup Svg element. --- elements/Svg.js | 12 +++++------- elements/Use.js | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/elements/Svg.js b/elements/Svg.js index bdd94984..1563b200 100644 --- a/elements/Svg.js +++ b/elements/Svg.js @@ -10,6 +10,7 @@ import { } from "react-native"; import extractViewBox from "../lib/extract/extractViewBox"; import { ViewBoxAttributes } from "../lib/attributes"; +import { numberProp } from "../lib/props"; /** @namespace NativeModules.RNSVGSvgViewManager */ const RNSVGSvgViewManager = NativeModules.RNSVGSvgViewManager; @@ -27,9 +28,9 @@ class Svg extends Component { static displayName = "Svg"; static propTypes = { ...ViewPropTypes, - opacity: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), - width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), - height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + opacity: numberProp, + width: numberProp, + height: numberProp, // more detail https://svgwg.org/svg2-draft/coords.html#ViewBoxAttribute viewBox: PropTypes.string, preserveAspectRatio: PropTypes.string @@ -41,10 +42,7 @@ class Svg extends Component { constructor() { super(...arguments); - id++; - this.id = id; - //noinspection JSUnusedGlobalSymbols - this.onDataURLCallbacks = []; + this.id = ++id; } measureInWindow = (...args) => { this.root.measureInWindow(...args); diff --git a/elements/Use.js b/elements/Use.js index f3edbc65..f2b02101 100644 --- a/elements/Use.js +++ b/elements/Use.js @@ -46,8 +46,8 @@ export default class extends Shape { }} {...extractProps(props, this)} href={href} - width={props.width} - height={props.height} + width={props.width.toString()} + height={props.height.toString()} > {props.children}