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

[Beats CM] Add check for BeatsPage component to avoid setState when unmounted #22836

Conversation

justinkambic
Copy link
Contributor

Changes

When loading the BeatsPage component from the Kibana Management plugin, React was giving the following warning:

warning.js:33 Warning: Can't call setState (or forceUpdate) 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 BeatsPage (created by Route)
    in Route (created by MainPages)
    in Switch (created by MainPages)
    in div (created by EuiPageContentBody)
    in EuiPageContentBody
    in div (created by EuiPanel)
    in EuiPanel (created by EuiPageContent)
    in EuiPageContent
    in div (created by EuiPageBody)
    in EuiPageBody
    in div (created by EuiPage)
    in EuiPage
    in Unknown (created by Route)
    in Route (created by withRouter())
    in withRouter() (created by MainPages)
    in MainPages (created by Route)
    in Route (created by PageRouter)
    in Switch (created by PageRouter)
    in Router (created by HashRouter)
    in HashRouter (created by PageRouter)
    in PageRouter

With the calls as they were, we were updating state on an unmounted component. With this change, we are adding a flag to signal whether or not the component is mounted; if loadBeats is called before the component has finished mounting, it will not call setState. There are no visual changes.

@justinkambic justinkambic added bug Fixes for quality problems that affect the customer experience Team:Beats v7.0.0 v6.5.0 Feature:beats-cm labels Sep 7, 2018
@justinkambic justinkambic changed the title Add check if component is unmounted when loading Beats List page. [Beats CM] Add check for BeatsPage component to avoid setState when unmounted Sep 7, 2018
@elasticmachine
Copy link
Contributor

💔 Build Failed

@justinkambic justinkambic merged commit 27a1485 into elastic:feature/x-pack/management/beats Sep 10, 2018
@justinkambic justinkambic deleted the ui/fix-beats-page-setstate-unmounted branch September 10, 2018 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:beats-cm Team:Beats v6.5.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants