jimmybow / visdcc

Dash Core Components for Visualization.
MIT License
144 stars 18 forks source link

Warning: Cannot update a component (`Connect(UnconnectedContainer)`) while rendering a different component (`Run_js`) #45

Open AdrianIssott opened 2 years ago

AdrianIssott commented 2 years ago

Running the https://github.com/jimmybow/visdcc/blob/master/example/Run_js/Add_event_and_callback.py example with:

Results in the following warning being output to the console:

react-dom@16.v2_3_1m1649084547.14.0.js:82 Warning: Cannot update a component (`Connect(UnconnectedContainer)`) while rendering a different component (`Run_js`). To locate the bad setState() call inside `Run_js`, follow the stack trace as described in https://fb.me/setstate-in-render
    in Run_js (created by CheckedComponent)
    in CheckedComponent (created by BaseTreeContainer)
    in ComponentErrorBoundary (created by BaseTreeContainer)
    in BaseTreeContainer (created by Context.Consumer)
    in Unknown (created by BaseTreeContainer)
    in div (created by it)
    in it (created by CheckedComponent)
    in CheckedComponent (created by BaseTreeContainer)
    in ComponentErrorBoundary (created by BaseTreeContainer)
    in BaseTreeContainer (created by Context.Consumer)
    in Unknown (created by UnconnectedContainer)
    in div (created by UnconnectedGlobalErrorContainer)
    in div (created by GlobalErrorOverlay)
    in div (created by GlobalErrorOverlay)
    in GlobalErrorOverlay (created by DebugMenu)
    in div (created by DebugMenu)
    in DebugMenu (created by UnconnectedGlobalErrorContainer)
    in div (created by UnconnectedGlobalErrorContainer)
    in UnconnectedGlobalErrorContainer (created by Connect(UnconnectedGlobalErrorContainer))
    in Connect(UnconnectedGlobalErrorContainer) (created by UnconnectedContainer)
    in UnconnectedContainer (created by Connect(UnconnectedContainer))
    in Connect(UnconnectedContainer) (created by UnconnectedAppContainer)
    in UnconnectedAppContainer (created by Connect(UnconnectedAppContainer))
    in Connect(UnconnectedAppContainer) (created by AppProvider)
    in Provider (created by AppProvider)
    in AppProvider

Nothing appears to actually go wrong but as this comment says "it points out legitimate issues that are likely causing bugs in your code" so would be good to fix.

jimmybow commented 2 years ago

thank you, but I don't know how to fix this warning message .... , should I update react.js version? if you off debug mode, this message will not show.

AdrianIssott commented 2 years ago

should I update react.js version?

I don't think that will help as the warning is pointing out a problem in run_js. According to this comment there was an improvement to how the warning was triggered in react 16.13.1 which we have (since the new version of the warning string is being output).

if you off debug mode, this message will not show.

Sure but that just silences the warning. It doesn't actually solve the underlying issue.

I don't know how to fix this warning message

Here are a few examples of it being fixed in other places:

Anyhow, isn't the problem this line: https://github.com/jimmybow/visdcc/blob/master/src/components/Run_js.react.js#L10? AIUI, the solution is to make the setProps call asynchronous in some way.