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

Adding shouldUpdate and onUpdate functions for customized rerendering #6

Merged
merged 1 commit into from Sep 20, 2017

Conversation

bfiss
Copy link
Contributor

@bfiss bfiss commented Sep 18, 2017

This is really important in large applications where rerendering everything is very costly.

Copy link
Owner

@gaearon gaearon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above two comments + we should add some tests for these functions.

src/index.js Outdated
@@ -24,13 +24,16 @@ function traverseRenderedChildren(internalInstance, callback, argument) {
}
}

function setPendingForceUpdate(internalInstance) {
function setPendingForceUpdate(internalInstance, shouldUpdate) {
if (shouldUpdate && !shouldUpdate(internalInstance)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the condition and instead pass a () => true function by default?

src/index.js Outdated
@@ -40,32 +43,37 @@ function forceUpdateIfPending(internalInstance) {
} else if (updater && typeof updater.enqueueForceUpdate === 'function') {
updater.enqueueForceUpdate(publicInstance);
}
onUpdate && onUpdate(internalInstance);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, let‘s pass an empty function by default and remove the branching.

@gaearon
Copy link
Owner

gaearon commented Sep 20, 2017

Follow up: please see #8.

@bfiss bfiss deleted the patch-1 branch September 20, 2017 22:46
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

Successfully merging this pull request may close these issues.

None yet

2 participants