UNPKG

@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)

19 lines (18 loc) 571 B
import { $$inject, detectIsComponent } from '../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[$$inject] = { token: $$memo, shouldUpdate, }; return factory; } const detectIsMemo = instance => detectIsComponent(instance) && instance.token === $$memo; export { memo, detectIsMemo }; //# sourceMappingURL=memo.js.map