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

Why forcing update of the whole tree? #72

Open
dbuezas opened this issue Mar 17, 2017 · 0 comments
Open

Why forcing update of the whole tree? #72

dbuezas opened this issue Mar 17, 2017 · 0 comments

Comments

@dbuezas
Copy link

dbuezas commented Mar 17, 2017

One could call forceUpdate just on the updated mounted instances. This way the amount of calls to render would be minimized and (more importantly) the reference to the root of the tree would become unnecessary.

I tried adding these lines at #createClassProxy.js:176 (branch 2.0.8) and it seems to work fine:

(code adapted from react-deep-force-update)

mountedInstances.forEach((publicInstance) => {
  if (typeof publicInstance.forceUpdate === 'function') {
    publicInstance.forceUpdate();
  } else if (publicInstance.updater && typeof publicInstance.updater.enqueueForceUpdate === 'function') {
    publicInstance.updater.enqueueForceUpdate(publicInstance);
  }
});

and seems to be a tiny bit faster.
Update:
I tested it in a real project: up to 5 times faster, no issues found, no react router warnings anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant