Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if (creating || loading) {
return;
}
let collectionChanged = false;
let addonsPageChanged = false;
if (prevProps && prevProps.location && location) {
if (prevProps.location.pathname !== location.pathname) {
collectionChanged = true;
}
}
if (prevProps && !deepEqual(prevProps.filters, filters)) {
addonsPageChanged = true;
}
if (collection) {
let isSameCollectionUser;
// Is `userId` a numeric ID?
if (/^\d+$/.test(params.userId)) {
isSameCollectionUser = `${collection.authorId}` === params.userId;
} else {
isSameCollectionUser =
collection.authorUsername.toLowerCase() ===
params.userId.toLowerCase();
}
if (
collection.slug.toLowerCase() !== params.slug.toLowerCase() ||
export function objectEqual(obj1, obj2) {
if (obj1 === obj2 || deepEql(obj1, obj2)) {
return true;
}
if (!obj1 || !obj2 || getEnumerableKeys(obj1).length !== getEnumerableKeys(obj2).length) {
return false;
}
// animation 写在标签上的进行判断是否相等, 判断每个参数有没有 function;
let equalBool = true;
const setEqualBool = ($a, $b) => {
const objA = getEnumerableKeys($a).length > getEnumerableKeys($b).length ? $a : $b;
const objB = getEnumerableKeys($a).length > getEnumerableKeys($b).length ? $b : $a;
getEnumerableKeys(objA).forEach((key) => {
// 如果前面有参数匹配不相同则直接返回;
if (!equalBool) {
return;
}
if (!(key in objB)) {
setValue(values = {}, type, forceSet) {
if (!forceSet && deepEqual(values, this.$values)) return
this.$values = deepMerge({}, values, { clone: true })
// wait render end.
setTimeout(() => {
Object.keys(this.$inputNames)
.sort((a, b) => a.length - b.length)
.forEach(name => {
this.dispatch(updateSubscribe(name), this.get(name), name, type)
this.dispatch(changeSubscribe(name))
})
// for flow
this.dispatch(CHANGE_TOPIC)
})
}
keysA.sort((a, b) => deep.indexOf(a) - deep.indexOf(b))
// Test for A's keys different from B.
for (let i = 0; i < keysA.length; i++) {
const k = keysA[i]
if (skip.includes(k)) continue
if (!hasOwnProperty.call(objB, k) || !is(objA[k], objB[k])) {
if (objA[k] instanceof Error && objB[k] instanceof Error) {
if (objA[k].message !== objB[k].message) return false
continue
}
if (deep.includes(k)) {
if (!deepEqual(objA[k], objB[k])) return false
} else {
return false
}
}
}
return true
}
shouldComponentUpdate = (nextProps, nextState) => {
return (
!deepEqual(this.props, nextProps) || !deepEqual(this.state, nextState)
);
};
shouldComponentUpdate(nextProps: Object, nextState: Object) {
return !deepEqual(nextProps, this.props) || nextState !== this.state;
}
getColumns(columns) {
if (deepEqual(columns, this.oldColumns)) {
return this.cachedColumns
}
const { onRowSelect, datum } = this.props
columns = columns.filter(c => typeof c === 'object')
let left = -1
let right = -1
columns.forEach((c, i) => {
if (c.fixed === 'left') left = i
if (c.fixed === 'right' && right < 0) right = i
})
this.cachedColumns = columns.map((c, i) =>
immer(c, draft => {
draft.index = i
if (draft.key === undefined) draft.key = i
pageParam,
paginate,
} = this.props;
if (!newAuthorIds) {
return;
}
const newPage = paginate
? oldLocation.query[pageParam] !== newLocation.query[pageParam]
: false;
if (
oldAddonType !== newAddonType ||
oldForAddonSlug !== newForAddonSlug ||
!deepEqual(oldAuthorIds, newAuthorIds) ||
newPage
) {
this.dispatchFetchAddonsByAuthors({
addonType: newAddonType,
authorIds: newAuthorIds,
forAddonSlug: newForAddonSlug,
page: this.getCurrentPage({
location: newLocation,
paginate,
pageParam,
}),
});
}
}
componentWillReceiveProps = nextProps => {
if (deepEqual(this.props, nextProps)) return;
this.clearCache(nextProps);
};