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)

17 lines (16 loc) 615 B
import { 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) { const memoized = props => factory(props).inject(shouldUpdate, $$memo); memoized.displayName = factory.displayName; return memoized; } const detectIsMemo = instance => detectIsComponent(instance) && instance.token === $$memo; export { memo, detectIsMemo }; //# sourceMappingURL=memo.js.map