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
Conversation
There was a problem hiding this 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)) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
… in large applications
Follow up: please see #8. |
This is really important in large applications where rerendering everything is very costly.