-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Serious performance issues related to React context #3057
Comments
The onClick is only added if there is an id, if you add an id it trigger the setProps all the time and the context get changed. I think the culprit is here:
It's a new layout object on every prop change, the topmost component is thus always updated. |
I noticed this back when using dmc 0.12, however, I utilized a workaround that will no longer work due to the dependence of Here is an example that is even slower for me:
Any selection change takes about 1 second to render. |
If you change here: dash/dash/dash-renderer/src/reducers/layout.js Lines 15 to 18 in fa7d30a
For const component = path(action.payload.itempath, state);
component.props = mergeRight(component.props, action.payload.props); Then only the component props will be updated in the redux store. But then the component doesn't update the props since they are passed down from the top components to the bottom, this is how it got the new props. We'll need to change the way the components get their props by using a selector on the redux state instead of the props being passed down. This can be done like: const componentProps = useSelector(state => path(concat(componentPath, ["props"]), state.layout)); When the props is updated it trigger the re-render in that selector only for that component. Just need to find a way (or refactor |
When using components associated with the
XxxProvider
, severe performance issues can arise when there is a large amount of page content. Here are some examples related to well-known component libraries in the Dash ecosystem:dmc
In
dmc
, it is required that the application be wrapped inside theMantineProvider
. With the React Developer Tools, you can see that any interaction with an internal component will trigger a re-render of all components on the current page.Even placing components from
dcc
under theMantineProvider
will cause the same issue:fac
In fac, the similar component
AntdConfigProvider
is not a must-use, but the same issue will also occur:However, the issue of global re-rendering does not occur with components within
html
, such as forhtml.Div
(which has the functionality to update the click event to the component'sn_clicks
property):dmc
fac
I hope to receive more help on this issue, to explore the deeper reasons and possible solutions.
The text was updated successfully, but these errors were encountered: