minor refactoring of component-connector

This commit is contained in:
Joffrey JAFFEUX 2017-11-21 15:48:56 +01:00 committed by GitHub
parent 5dd890eb3d
commit b76154ec36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -31,6 +31,10 @@ export default class ComponentConnector {
}
update(prev) {
// mutated external properties might not correctly update the underlying component
// in this case we can define trackedProperties, if different from previous
// state we will re-init the whole component, be careful when using this
// to not track a property which would be updated too often (on scroll for example)
let shouldInit = false;
this.trackedProperties.forEach(prop => {
if (prev.opts[prop] !== this.opts[prop]) {
@ -38,7 +42,7 @@ export default class ComponentConnector {
}
});
if (shouldInit === true) return this.init();
if (shouldInit) return this.init();
return null;
}