-
Notifications
You must be signed in to change notification settings - Fork 121
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
onBrushEnd should be called after setState is completed #360
Comments
If onBrush callback is invoked as the second argument of We should be good I think to remove the
In the stack trace above @angorayc , there is an inner stack trace which points to the onBrushEnd as the culprit:
|
Sorry for the delay, I'll look into this today! |
@angorayc I think I see the issue but I am not able to reproduce the error locally. Can you provide your Just looking at the code in question I see that there is a potential for a race condition to occur if this window
is invoked before the state is updated here elastic-charts/src/components/react_canvas/reactive_chart.tsx Lines 305 to 309 in 94d5a51
It seems like this scenario is unlikely for a user to be able to click AND drag before the react state is updated. But if that is the case we can handle that by only calling the listener when the state is updated. As soon as you send me a snippet I can understand the root cause of your error. |
Hi @nickofthyme, The lines of code are for our hosts page: And here for our network page: If you remove that ${root}/app/siem#/hosts/ ${root}/app/siem#/network you will see the error. What happens is during a Here is where we trigger a redux change which eventually can lead to a |
Wait for setState to finish before calling onBrushEnd, in the event the callback triggers a rerender. fixes elastic#360
@FrankHassanabad sorry I was looking at the wrong elastic-charts/src/components/react_canvas/reactive_chart.tsx Lines 323 to 328 in eb482be
#376 should fix it. I tested it locally in SIEM and worked without error. Also thanks for showing me how to ingest data with |
🎉 This issue has been resolved in version 12.0.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
## [12.0.2](elastic/elastic-charts@v12.0.1...v12.0.2) (2019-09-16) ### Bug Fixes * **reactive_chart:** fix order of instantiation of onBruchEnd callback ([opensearch-project#376](elastic/elastic-charts#376)) ([42cd1e7](elastic/elastic-charts@42cd1e7)), closes [opensearch-project#360](elastic/elastic-charts#360)
Describe the bug
If onBrushEnd is given, it should call it after
setState
is completed, otherwise it occurs warnings about setting state when unmount.For example, this is the function I am passing to
onBrushEnd
:The reason why I'm waiting for 500ms here is to make sure
setState is completed
.https://github.com/elastic/elastic-charts/blob/master/src/components/react_canvas/reactive_chart.tsx#L305
Expected behavior
onBrushEnd should be called
after
setState is completedScreenshots
If I remove
setTimeout
:Errors in browser console
Kibana Cross Issues
Add any Kibana related issues here.
Checklist
Kibana Cross Issues
listkibana cross issue
tag is associated to the issue if any kibana cross issue is presentThe text was updated successfully, but these errors were encountered: