refactor Components props extracting

This commit is contained in:
Horcrux
2017-02-03 19:43:25 +08:00
parent 9b62d500ce
commit 5bd9b40c17
35 changed files with 208 additions and 276 deletions
+7 -11
View File
@@ -1,12 +1,12 @@
import {PropTypes} from 'react';
import React, {PropTypes} from 'react';
import createReactNativeComponentClass from 'react-native/Libraries/Renderer/src/renderers/native/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 createReactNativeComponentClass from 'react-native/Libraries/Renderer/src/renderers/native/createReactNativeComponentClass';
const idExpReg = /^#(.+)$/;
class Use extends Shape {
export default class extends Shape {
static displayName = 'Use';
static propTypes = {
@@ -21,9 +21,9 @@ class Use extends Shape {
};
render() {
let {props} = this;
const {props} = this;
// match "url(#pattern)"
let matched = props.href.match(idExpReg);
const matched = props.href.match(idExpReg);
let href;
if (matched) {
@@ -34,11 +34,9 @@ class Use extends Shape {
console.warn('Invalid `href` prop for `Use` element, expected a href like `"#id"`, but got: "' + props.href + '"');
}
let extractedProps = this.extractProps(props);
return <RNSVGUse
ref={ele => {this.root = ele;}}
{...extractedProps}
{...extractProps(props, this)}
href={href}
width={props.width}
height={props.height}
@@ -51,5 +49,3 @@ const RNSVGUse = createReactNativeComponentClass({
uiViewClassName: 'RNSVGUse'
});
export default Use;