import { flatten } from 'lodash' export const forceArray = (children: any) => flatten(children && children.length ? children : [children]) export const childrenChanged = (oldChildren: any, newChildren: any): boolean => { const olds = forceArray(oldChildren) const news = forceArray(newChildren) if (olds.length !== news.length) return true if (olds.length === 0 && news.length === 0) return false for (let idx = 0; idx < olds.length; idx++) { if (!olds[idx] && !news[idx]) { continue } if (!olds[idx] && news[idx]) return true if (olds[idx] && !news[idx]) return true if ((olds[idx] as any).key !== (news[idx] as any).key) return true } return false }