UNPKG

react-native-svg

Version:
43 lines (36 loc) 985 B
import React from "react"; import Path from "./Path"; import extractPolyPoints from "../lib/extract/extractPolyPoints"; import Shape from "./Shape"; export default class extends Shape { static displayName = "Polyline"; static defaultProps = { points: "", }; setNativeProps = props => { let { points } = props; if (points) { if (Array.isArray(points)) { points = points.join(","); } props.d = `M${extractPolyPoints(points)}`; } this.root.setNativeProps(props); }; render() { const { props } = this; let { points } = props; if (Array.isArray(points)) { points = points.join(","); } return ( <Path ref={ele => { this.root = ele; }} {...this.props} d={`M${extractPolyPoints(points)}`} /> ); } }