Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/factory/createReducer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MutableRefObject, useCallback, useRef, useState } from 'react';
import useUpdateEffect from '../useUpdateEffect';

type Dispatch<Action> = (action: Action) => void;
type Dispatch<Action> = (action: Action) => Action;

interface Store<Action, State> {
getState: () => State;
Expand Down
8 changes: 0 additions & 8 deletions src/useDeepCompareEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@ import { DependencyList, EffectCallback } from 'react';
import useCustomCompareEffect from './useCustomCompareEffect';
import isDeepEqual from './misc/isDeepEqual';

const isPrimitive = (val: any) => val !== Object(val);

const useDeepCompareEffect = (effect: EffectCallback, deps: DependencyList) => {
if (process.env.NODE_ENV !== 'production') {
if (!(deps instanceof Array) || !deps.length) {
console.warn(
'`useDeepCompareEffect` should not be used with no dependencies. Use React.useEffect instead.'
);
}

if (deps.every(isPrimitive)) {
console.warn(
'`useDeepCompareEffect` should not be used with dependencies that are all primitive values. Use React.useEffect instead.'
);
}
}

useCustomCompareEffect(effect, deps, isDeepEqual);
Expand Down