★ wanayoo — archive 1999 https://github.com/plotly/react-plotly.js/issues/18Nouvelle recherche | Portail wanayoo
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

Handling state change in component using react-plotly <Plot> #18

Closed
mhoffman opened this issue Nov 16, 2017 · 3 comments
Closed

Handling state change in component using react-plotly <Plot> #18

mhoffman opened this issue Nov 16, 2017 · 3 comments
Assignees
Labels
bug

Comments

@mhoffman
Copy link

@mhoffman mhoffman commented Nov 16, 2017

Are state multiples changes supported in combination with onClick events? Here is an example of what I intend to do https://codepen.io/mjhoffmann/pen/qVVEaZ .

  1. Steps to reproduce issue
    Click on one bar, then click on another bar

  2. What I would except to happen
    The caption "Selected ..." should change on every click

  3. What happens instead
    The caption changes only on the first click but not on any further events.

Is this supported? What is the right way to implement this. Many thanks.

@bpostlethwaite bpostlethwaite self-assigned this Nov 16, 2017
@bpostlethwaite bpostlethwaite added the bug label Nov 16, 2017
@bpostlethwaite
Copy link
Member

@bpostlethwaite bpostlethwaite commented Nov 16, 2017

Thank you for your report and codepen. It's a bug! I'll update this issue once fixed and published.


The bug stems from the fact that this module is running on top of Plotly.newPlot which runs a purge routine on every invocation. purge wipes the event listeners from plotly.js but react-plotly.js does not likewise clear its references. react-plotly.js assumes the handlers are still in place and so does not update them.

The fix will be to clear react-plotly.js handlers on every Plotly.newPlot invocation so it will know to re-register them.

@mhoffman
Copy link
Author

@mhoffman mhoffman commented Nov 16, 2017

Thanks for the quick reply. I very much like the fact that you are supporting React.

@bpostlethwaite
Copy link
Member

@bpostlethwaite bpostlethwaite commented Nov 17, 2017

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.