Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event Handlers Don't Update #150

Open
gonzofish opened this issue Jul 1, 2019 · 0 comments
Open

Event Handlers Don't Update #150

gonzofish opened this issue Jul 1, 2019 · 0 comments

Comments

@gonzofish
Copy link

gonzofish commented Jul 1, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant