mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-20 22:05:14 +00:00
due to the peerDependency of react-native is >=0.29.0. so there is no need to consider compatibility with react-native@0.27.0 and below.
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import React, {Component, PropTypes} from 'react';
|
|
import {set, remove} from '../lib/extract/extractClipping';
|
|
import createReactNativeComponentClass from 'react/lib/createReactNativeComponentClass';
|
|
import {ClipPathAttributes} from '../lib/attributes';
|
|
|
|
class ClipPath extends Component{
|
|
static displayName = 'ClipPath';
|
|
static propTypes = {
|
|
id: PropTypes.string.isRequired
|
|
};
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
this.id = this.props.id + ':' + this.props.svgId;
|
|
}
|
|
|
|
componentWillReceiveProps = nextProps => {
|
|
let id = nextProps.id + ':' + nextProps.svgId;
|
|
if (id !== this.id) {
|
|
remove(this.id);
|
|
}
|
|
};
|
|
|
|
componentWillUnmount = () => {
|
|
remove(this.id);
|
|
};
|
|
|
|
render() {
|
|
set(this.id, this.id);
|
|
return <RNSVGClipPath
|
|
name={this.id}
|
|
>{this.props.children}</RNSVGClipPath>;
|
|
}
|
|
}
|
|
|
|
const RNSVGClipPath = createReactNativeComponentClass({
|
|
validAttributes: ClipPathAttributes,
|
|
uiViewClassName: 'RNSVGClipPath'
|
|
});
|
|
|
|
export default ClipPath;
|
|
|