mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-22 23:25:20 +00:00
Merge branch 'master' into NativeAnimation
# Conflicts: # android/src/main/java/com/horcrux/svg/RenderableShadowNode.java # android/src/main/java/com/horcrux/svg/SvgViewShadowNode.java # elements/Image.js # elements/Rect.js # elements/Use.js # lib/attributes.js
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import createReactNativeComponentClass from '../lib/createReactNativeComponentClass';
|
||||
import extractProps from '../lib/extract/extractProps';
|
||||
import {pathProps, numberProp} from '../lib/props';
|
||||
import {UseAttributes} from '../lib/attributes';
|
||||
import Shape from './Shape';
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { requireNativeComponent } from "react-native";
|
||||
import extractProps from "../lib/extract/extractProps";
|
||||
import { pathProps, numberProp } from "../lib/props";
|
||||
import { UseAttributes } from "../lib/attributes";
|
||||
import Shape from "./Shape";
|
||||
|
||||
const idExpReg = /^#(.+)$/;
|
||||
export default class extends Shape {
|
||||
static displayName = 'Use';
|
||||
static displayName = "Use";
|
||||
|
||||
static propTypes = {
|
||||
href: PropTypes.string.isRequired,
|
||||
@@ -17,12 +17,18 @@ export default class extends Shape {
|
||||
...pathProps
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
width: 0,
|
||||
height: 0
|
||||
};
|
||||
|
||||
setNativeProps = (...args) => {
|
||||
this.root.setNativeProps(...args);
|
||||
};
|
||||
|
||||
render() {
|
||||
const {props} = this;
|
||||
const { props } = this;
|
||||
const { children, width, height } = props;
|
||||
// match "url(#pattern)"
|
||||
const matched = props.href.match(idExpReg);
|
||||
let href;
|
||||
@@ -32,20 +38,29 @@ export default class extends Shape {
|
||||
}
|
||||
|
||||
if (!href) {
|
||||
console.warn('Invalid `href` prop for `Use` element, expected a href like `"#id"`, but got: "' + props.href + '"');
|
||||
console.warn(
|
||||
'Invalid `href` prop for `Use` element, expected a href like `"#id"`, but got: "' +
|
||||
props.href +
|
||||
'"'
|
||||
);
|
||||
}
|
||||
|
||||
return <RNSVGUse
|
||||
ref={ele => {this.root = ele;}}
|
||||
{...extractProps(props, this)}
|
||||
href={href}
|
||||
usewidth={props.width}
|
||||
useheight={props.height}
|
||||
>{props.children}</RNSVGUse>;
|
||||
return (
|
||||
<RNSVGUse
|
||||
ref={ele => {
|
||||
this.root = ele;
|
||||
}}
|
||||
{...extractProps(props, this)}
|
||||
href={href}
|
||||
usewidth={width !== undefined ? width.toString() : ""}
|
||||
useheight={height !== undefined ? height.toString() : ""}
|
||||
>
|
||||
{children}
|
||||
</RNSVGUse>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const RNSVGUse = createReactNativeComponentClass('RNSVGUse', () => ({
|
||||
validAttributes: UseAttributes,
|
||||
uiViewClassName: 'RNSVGUse'
|
||||
}));
|
||||
const RNSVGUse = requireNativeComponent("RNSVGUse", null, {
|
||||
nativeOnly: UseAttributes
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user