@dark-engine/core
Version:
The lightweight and powerful UI rendering engine without dependencies and written in TypeScript (Browser, Node.js, Android, iOS, Windows, Linux, macOS)
23 lines (22 loc) • 735 B
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
exports.detectIsMemo = exports.memo = void 0;
const component_1 = require('../component');
const $$memo = Symbol('memo');
const defaultShouldUpdate = (props, nextProps) => {
for (const key in nextProps) {
if (key !== 'slot' && nextProps[key] !== props[key]) return true;
}
return false;
};
function memo(factory, shouldUpdate = defaultShouldUpdate) {
factory[component_1.$$inject] = {
token: $$memo,
shouldUpdate,
};
return factory;
}
exports.memo = memo;
const detectIsMemo = instance => (0, component_1.detectIsComponent)(instance) && instance.token === $$memo;
exports.detectIsMemo = detectIsMemo;
//# sourceMappingURL=memo.js.map