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);
};
static getDerivedStateFromProps(nextProps, prevState) {
const { prevProps = {} } = prevState;
const newState = {
prevProps: nextProps,
};
if ('value' in nextProps && !shallowEqualArrays(prevProps.value, nextProps.value)) {
newState.value = nextProps.value || [];
// allow activeValue diff from value
if (!('loadData' in nextProps)) {
newState.activeValue = nextProps.value || [];
}
newState.inputValue = self.convertStringToObject(self.props.options,nextProps,[],0,).map(o =>o.label).join('/ ') || ''
}
if ('popupVisible' in nextProps) {
newState.popupVisible = nextProps.popupVisible;
}
if ('options' in nextProps) {
newState.options = nextProps.options || [];
}
if ('inputValue' in nextProps) {
newState.inputValue = nextProps.inputValue;
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;
};