plotly / plotly/react-plotly.js

Event Handlers Don't Update

未关闭
#150 0 条评论 6 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
JavaScript
星标
1.1k
派生
138
平均合并
3 天 2 小时
30 天内合并 PR
4

描述

I'm using 2.3.0 and noticed that the code doesn't account for an event handler prop changing. So, for instance, if I have a component with:

const MyComponent = ({ someCallback }) => (
   <Plot
     data={data}
     onRelayout={someCallback}
   />
);

The someCallback that is called is the first one. Here's a Codepen reproducing:

https://codepen.io/gonzofish/pen/OevOjx

To see it in action, just click autoscale on the chart and you'll see the message change to "Callback 1 Reporting In". If you change the callback by clicking "Change to 2" and then clicking autoscale again, the message doesn't change, despite the callback being changed.

I believe the issues stems from syncEventHandlers only account for two modes: (1) the handler isn't already set but has been provided as a prop and (2) the handler was set but the prop is not longer there. That starts at:

https://github.com/plotly/react-plotly.js/blob/master/src/factory.js#L212

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 src/factory.js 第 212 行附近开始,查看 syncEventHandlers 处理 plot 事件 props 的位置,并使用链接的 CodePen 复现来观察 callback 的变化。完成标准是:更改 onRelayout prop 后,下一个 autoscale 事件调用新的 callback,而不是原来的 callback。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, react
领域
data-visualization, frontend
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
描述清楚
新手友好度
50/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。