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

New onDirectUpdate callback triggerered on render #751

Closed
jonmmease opened this issue Oct 2, 2018 · 5 comments
Closed

New onDirectUpdate callback triggerered on render #751

jonmmease opened this issue Oct 2, 2018 · 5 comments

Comments

@jonmmease
Copy link

It seems that the new onDirectUpdate callback added in #749 is executed on render as well as on direct manipulation of the plot.

The JupyterLab extension currently registers an onUpdate callback that is executed when the user manipulates the figure using the React widgets. This callback is used to set the state of the extension's ChartEditor component.

I tried to register the same callback function with the new onDirectUpdate property and ended up in an infinite loop. I think what's happening is that rendering PlotlyEditor is triggering the onDirectUpdate callback, which then calls setState, which then causes another render, and on and on.

Please let me know if I'm misunderstanding something here about the intended use of onDirectUpdate. But I'm wondering if it would be possible for onDirectUpdate to not execute on the initial render, and only in response to mouse interactions.

Or alternatively, should the onDirectUpdate callback function not be calling setState at all? Because the plotly figure was already updated internally?

Thanks!

@nicolaskruchten
Copy link
Contributor

nicolaskruchten commented Oct 2, 2018 via email

@jonmmease
Copy link
Author

Ok, well if I just don't set the state everything seems to work fine (See https://github.com/plotly/jupyterlab-chart-editor/pull/24/commits/2374ee94665d7b8b5e725d4904d26fb3efd42092)

@nicolaskruchten
Copy link
Contributor

nicolaskruchten commented Oct 2, 2018 via email

@nicolaskruchten
Copy link
Contributor

See #754

@nicolaskruchten
Copy link
Contributor

OK, this change was published as v0.31.1

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

2 participants