-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
Comments
Ah yeah I hadn’t thought about that... probably you shouldn’t use this to
set state and I should rename it onRender :)
…On Mon, Oct 1, 2018 at 20:16 Jon Mease ***@***.***> wrote:
It seems that the new onDirectUpdate callback added in #749
<#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!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#751>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AAMbAyqu_5A5at7Vcc07qVynXwvzntI-ks5ugrBCgaJpZM4XDG3m>
.
|
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) |
Yeah, the PlotlyEditor keeps its own state so that should work. It’s a
pretty brittle system, prone to infinite loops unfortunately. I’ll still
likely rename that function just for clarity, sorry for the churn.
…On Mon, Oct 1, 2018 at 20:33 Jon Mease ***@***.***> wrote:
Ok, well if I just don't set the state everything seems to work fine (See
***@***.***
<plotly/jupyterlab-chart-editor@2374ee9>
)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#751 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMbAwXp6ijdc6EUQhc3TPNN2Fw37hMvks5ugrRAgaJpZM4XDG3m>
.
|
See #754 |
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
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'sChartEditor
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 renderingPlotlyEditor
is triggering theonDirectUpdate
callback, which then callssetState
, which then causes anotherrender
, 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 foronDirectUpdate
to not execute on the initial render, and only in response to mouse interactions.Or alternatively, should the
onDirectUpdate
callback function not be callingsetState
at all? Because the plotly figure was already updated internally?Thanks!
The text was updated successfully, but these errors were encountered: