有没有一种方法可以将事件从d3分发到React

时间:2019-03-27 18:54:44

标签: reactjs d3.js events

我需要将事件从d3调度到处理该事件的Reach。 我有handleClick方法

function handleClick(d) {      
   d3.select(this)
      .attr("stroke", "blue")
      .attr("stroke-width", "2")
      .dispatch("select");

}

,将stroke属性添加到选定的rect元素,并假定调度“ select”事件。 在componentDidMount中,我添加了

const dispatch = d3.dispatch('select', 'unselect');
dispatch.on('select', this.handleSelectEvent)

,但不起作用。 您可以在https://stackblitz.com/edit/react-d3-tree

中查看完整的代码

0 个答案:

没有答案
相关问题