Skip to content

onBrushEnd should be called after setState is completed #360

@angorayc

Description

@angorayc

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:

(min: number, max: number) => {
  setTimeout(() => {
    setAbsoluteRangeDatePicker({ id: 'global', from: min, to: max });
  }, 500);
}

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 completed

Screenshots
If I remove setTimeout:

onBrushEnd

Errors in browser console

backend.js:1 Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
    in ReactiveChart
    in inject-ReactiveChart-with-chartStore
    in div
    in ChartContainer
    in inject-ChartContainer-with-chartStore
    in div
    in div
    in Provider
    in Chart
    in div
    in Unknown
    in Unknown (created by AutoSizer)
    in div (created by WrappedByAutoSizer)
    in WrappedByAutoSizer (created by AutoSizer)
    in AutoSizer
    in Unknown
    in div (created by EuiFlexItem)
    in EuiFlexItem (created by FlexItem)
    in FlexItem
    in div (created by EuiFlexGroup)
    in EuiFlexGroup
    in div (created by EuiPanel)
    in EuiPanel
    in div (created by EuiFlexItem)
    in EuiFlexItem (created by FlexItem)
    in FlexItem
    in Unknown
    in div (created by EuiFlexGroup)
    in EuiFlexGroup

Kibana Cross Issues
Add any Kibana related issues here.

Checklist

  • every related Kibana issue is listed under Kibana Cross Issues list
  • kibana cross issue tag is associated to the issue if any kibana cross issue is present

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingreleasedIssue released publicly

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions