A react add-on for drawing polygons for any number of sides, as well as animation
A react add-on for drawing polygons for any number of sides, as well as animation
https://peteroid.github.io/react-polygon/
npm install react-polygon --save
import Polygon from 'react-polygon'
// add this to your components
<Polygon />
npm install
npm run webpack
name : propType = defaultValue
You can render extra elements on each point by passing a function to the props renderPoint
. Here is an example for rendering a point on each vertice:
import React, { Component } from 'react'
import Polygon from 'react-polygon'
class MyPolygon extends Component {
myRenderPoint (point) {
return (
<circle cx={point[0]} cy={point[1]} r={5} />
)
}
render () {
return (
<Polygon renderPoint={this.myRenderPoint} />
)
}
}