/* global d3 */
import React from 'react'
class TimelineCategories extends React.Component {
constructor () {
super()
this.grabRef = React.createRef()
this.state = {
isInitialized: false
}
}
componentDidUpdate () {
if (!this.state.isInitialized) {
const drag = d3.drag()
.on('start', this.props.onDragStart)
.on('drag', this.props.onDrag)
.on('end', this.props.onDragEnd)
d3.select(this.grabRef.current)
.call(drag)
this.setState({ isInitialized: true })
}
}
renderCategory (category, idx) {
const dims = this.props.dims
return (
{category.category}
)
}
render () {
const dims = this.props.dims
return (
{this.props.categories.map((cat, idx) => this.renderCategory(cat, idx))}
)
}
}
export default TimelineCategories