Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const defaultShouldTokenize = ({hunks: currentHunks, ...currentPayload}, {hunks: prevHunks, ...prevPayload}) => {
if (currentPayload.oldSource !== prevPayload.oldSource) {
return true;
}
// When `oldSource` is provided, we can get the new source by applying diff,
// so when hunks keep identical, the tokenize result will always remain the same.
if (currentPayload.oldSource) {
return !shallowEquals(currentPayload, prevPayload) || !areHunksEqual(currentHunks, prevHunks);
}
return currentHunks !== prevHunks || !shallowEquals(currentPayload, prevPayload);
};
useEffect(() => {
const newDevice = getDevice()
if (!areObjectsEqual(device, newDevice)) {
setDevice(newDevice)
}
}, [deviceFromProps, deviceFromContext])
componentWillReceiveProps (nextProps) {
if (shallowEqual(this.props, nextProps)) return
const stateOverride = pick(nextProps, controllableProps)
this.store.controlledUpdate(stateOverride)
}
export const isActive = (state, {pathname, query}) => {
const {
pathname: prevPathname,
cleanQuery: prevCleanQuery
} = state;
const {
pathname: nextPathname,
cleanQuery: nextCleanQuery
} = changeParams(state, {pathname, query});
return shallowEqual(nextCleanQuery, prevCleanQuery) && nextPathname === prevPathname;
};
export function bookSearchReducer(state = initialState, action): BookSearchState {
switch (action.type) {
case SET_BASIC_LIST_VIEW:
localStorage.set("book-ui", BASIC_LIST_VIEW);
return { ...state, view: BASIC_LIST_VIEW };
case SET_GRID_VIEW:
localStorage.set("book-ui", GRID_VIEW);
return { ...state, view: GRID_VIEW };
case SET_COVERS_LIST_VIEW:
localStorage.set("book-ui", COVERS_LIST);
return { ...state, view: COVERS_LIST };
case HASH_CHANGED:
let { filters } = action;
if (!shallowEqual(filters, state.hashFilters)) {
return { ...state, hashFilters: filters };
}
return { ...state };
}
return state;
}
componentDidUpdate( prevProps ) {
if ( shallowEqual( this.props.query, prevProps.query ) ) {
return;
}
this.props.requestDones( this.props.query );
}
shouldUpdate((
{ objectIds, ...props },
{ objectIds: nextObjectIds, ...nextProps }
) => {
const out = !(
objectIds.equals(nextObjectIds)
&& shallowEqualObjects(
props,
nextProps, ['shouldFetch', 'isLoading']
)
);
return out;
}),
)(fullActivitiesList);
export function bookSearchReducer(state = initialState, action): BookSearchType {
switch (action.type) {
case SET_BASIC_LIST_VIEW:
return { ...state, view: BASIC_LIST_VIEW };
case SET_GRID_VIEW:
return { ...state, view: GRID_VIEW };
case HASH_CHANGED:
let { filters } = action;
if (!shallowEqual(filters, state.hashFilters)) {
return { ...state, hashFilters: filters };
}
return { ...state };
}
return state;
}
export const componentRouter = (state = initialState, {type, ...payload}) => {
const newState = reduce(state, {type, ...payload});
return shallowEqual(state, newState) ? state : newState;
};
export const changeParams = (state, params) => {
const {defaultParams, query, pathname} = state;
const newQuery = sortedObject({...defaultParams, ...query, ...safeQuery(params.query)});
const newPathname = params.pathname || pathname;
if (shallowEqual(newQuery, query) && newPathname === pathname) {
return state;
}
const cleanQuery = cleanupQuery({query: newQuery, defaultParams});
const currentRoute = matchRoute(state.routes)(newPathname);
return {
...state,
query: newQuery,
pathname: newPathname,
cleanQuery,
currentRoute
};
};