react-native-svg
Version:
SVG library for react-native
59 lines (50 loc) • 1.54 kB
JavaScript
import React, { PropTypes } from 'react';
import createReactNativeComponentClass from 'react-native/Libraries/Renderer/src/renderers/native/createReactNativeComponentClass';
import extractText from '../lib/extract/extractText';
import {numberProp, pathProps, fontProps} from '../lib/props';
import {TSpanAttibutes} from '../lib/attributes';
import extractProps from '../lib/extract/extractProps';
import Shape from './Shape';
// TSpan elements are shadow components
export default class extends Shape {
static displayName = 'TSpan';
static propTypes = {
...pathProps,
...fontProps,
dx: numberProp,
dy: numberProp,
textAnchor: PropTypes.oneOf(['start', 'middle', 'end'])
};
static childContextTypes = {
isInAParentText: React.PropTypes.bool
};
getChildContext() {
return {
isInAParentText: true
};
};
getContextTypes() {
return {
isInAParentText: React.PropTypes.bool
};
};
setNativeProps = (...args) => {
this.root.setNativeProps(...args);
};
render() {
let props = this.props;
return <RNSVGTSpan
ref={ele => {this.root = ele;}}
{...extractProps({
...props,
x: null,
y: null
}, this)}
{...extractText(props)}
/>;
}
}
const RNSVGTSpan = createReactNativeComponentClass({
validAttributes: TSpanAttibutes,
uiViewClassName: 'RNSVGTSpan'
});