mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-05 16:04:38 +00:00
[js] optimize object allocations
This commit is contained in:
+12
-18
@@ -15,29 +15,23 @@ export default class TSpan extends Shape {
|
||||
props.matrix = matrix;
|
||||
}
|
||||
const prop = propsAndStyles(props);
|
||||
const text = pickNotNil(extractText(prop, false));
|
||||
this.root.setNativeProps({
|
||||
...prop,
|
||||
...text,
|
||||
});
|
||||
Object.assign(prop, pickNotNil(extractText(prop, false)));
|
||||
this.root.setNativeProps(prop);
|
||||
};
|
||||
|
||||
render() {
|
||||
const prop = propsAndStyles(this.props);
|
||||
return (
|
||||
<RNSVGTSpan
|
||||
ref={this.refMethod}
|
||||
{...extractProps(
|
||||
{
|
||||
...prop,
|
||||
x: null,
|
||||
y: null,
|
||||
},
|
||||
this,
|
||||
)}
|
||||
{...extractText(prop, false)}
|
||||
/>
|
||||
const props = extractProps(
|
||||
{
|
||||
...prop,
|
||||
x: null,
|
||||
y: null,
|
||||
},
|
||||
this,
|
||||
);
|
||||
Object.assign(props, extractText(prop, false));
|
||||
props.ref = this.refMethod;
|
||||
return <RNSVGTSpan {...props} />;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-18
@@ -16,29 +16,23 @@ export default class Text extends Shape {
|
||||
props.matrix = matrix;
|
||||
}
|
||||
const prop = propsAndStyles(props);
|
||||
const text = pickNotNil(extractText(prop, true));
|
||||
this.root.setNativeProps({
|
||||
...prop,
|
||||
...text,
|
||||
});
|
||||
Object.assign(prop, pickNotNil(extractText(prop, true)));
|
||||
this.root.setNativeProps(prop);
|
||||
};
|
||||
|
||||
render() {
|
||||
const prop = propsAndStyles(this.props);
|
||||
return (
|
||||
<RNSVGText
|
||||
ref={this.refMethod}
|
||||
{...extractProps(
|
||||
{
|
||||
...prop,
|
||||
x: null,
|
||||
y: null,
|
||||
},
|
||||
this,
|
||||
)}
|
||||
{...extractText(prop, true)}
|
||||
/>
|
||||
const props = extractProps(
|
||||
{
|
||||
...prop,
|
||||
x: null,
|
||||
y: null,
|
||||
},
|
||||
this,
|
||||
);
|
||||
Object.assign(props, extractText(prop, true));
|
||||
props.ref = this.refMethod;
|
||||
return <RNSVGText {...props} />;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+31
-34
@@ -15,11 +15,8 @@ export default class TextPath extends Shape {
|
||||
if (matrix) {
|
||||
props.matrix = matrix;
|
||||
}
|
||||
const text = pickNotNil(extractText(props, true));
|
||||
this.root.setNativeProps({
|
||||
...props,
|
||||
...text,
|
||||
});
|
||||
Object.assign(props, pickNotNil(extractText(props, true)));
|
||||
this.root.setNativeProps(props);
|
||||
};
|
||||
|
||||
render() {
|
||||
@@ -27,45 +24,45 @@ export default class TextPath extends Shape {
|
||||
children,
|
||||
xlinkHref,
|
||||
href = xlinkHref,
|
||||
startOffset,
|
||||
startOffset = 0,
|
||||
method,
|
||||
spacing,
|
||||
side,
|
||||
alignmentBaseline,
|
||||
midLine,
|
||||
...props
|
||||
...prop
|
||||
} = this.props;
|
||||
const matched = href && href.match(idPattern);
|
||||
const match = matched && matched[1];
|
||||
if (match) {
|
||||
return (
|
||||
<RNSVGTextPath
|
||||
ref={this.refMethod}
|
||||
{...extractProps(
|
||||
{
|
||||
...propsAndStyles(props),
|
||||
x: null,
|
||||
y: null,
|
||||
},
|
||||
this,
|
||||
)}
|
||||
{...extractText(
|
||||
{
|
||||
children,
|
||||
},
|
||||
true,
|
||||
)}
|
||||
{...{
|
||||
href: match,
|
||||
startOffset: startOffset || 0,
|
||||
method,
|
||||
spacing,
|
||||
side,
|
||||
alignmentBaseline,
|
||||
midLine,
|
||||
}}
|
||||
/>
|
||||
const props = extractProps(
|
||||
{
|
||||
...propsAndStyles(prop),
|
||||
x: null,
|
||||
y: null,
|
||||
},
|
||||
this,
|
||||
);
|
||||
Object.assign(
|
||||
props,
|
||||
extractText(
|
||||
{
|
||||
children,
|
||||
},
|
||||
true,
|
||||
),
|
||||
{
|
||||
href: match,
|
||||
startOffset,
|
||||
method,
|
||||
spacing,
|
||||
side,
|
||||
alignmentBaseline,
|
||||
midLine,
|
||||
},
|
||||
);
|
||||
props.ref = this.refMethod;
|
||||
return <RNSVGTextPath {...props} />;
|
||||
}
|
||||
|
||||
console.warn(
|
||||
|
||||
Reference in New Issue
Block a user