UNPKG

redext

Version:

A simple global store based on React Context and Hooks

24 lines (23 loc) 615 B
// src/utils/index.ts var shallowDiffers = (prev, next) => { for (let attribute in prev) { if (!(attribute in next)) { return true; } } for (let attribute in next) { if (JSON.stringify(prev[attribute]) !== JSON.stringify(next[attribute])) { return true; } } return false; }; var memoPropsAreEqual = (prevProps, nextProps) => { const { style: prevStyle, ...prevRest } = prevProps; const { style: nextStyle, ...nextRest } = nextProps; return !shallowDiffers(prevStyle, nextStyle) && !shallowDiffers(prevRest, nextRest); }; export { memoPropsAreEqual, shallowDiffers };