Skip to content

Commit d5a6e9b

Browse files
author
k.golikov
committed
Improve debouncedMemo
1 parent e3ca07a commit d5a6e9b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/hooks/debouncedMemo.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import call from '../utils/call';
55
import useAutoRef from './useAutoRef';
66

77
interface NoResult {
8-
_noResult: string;
8+
readonly _noResult: string;
99
}
1010

1111
const isNoResult = <T>(value: T | NoResult, noResult: NoResult): value is NoResult => {
12-
return isObject(value) && '_noResult' in value && value._noResult === noResult._noResult; //TODO just value === noResult ?
12+
return isObject(value) && '_noResult' in value && value === noResult; //TODO just value === noResult ?
1313
};
1414

1515
type MemoFactory<R> = (noResult: NoResult) => R | NoResult;
@@ -22,9 +22,9 @@ const createDebouncedMemoHook =
2222

2323
const debounceFunction = useRef(
2424
call(() => {
25-
const actualNoResult: NoResult = {
25+
const actualNoResult: NoResult = Object.freeze({
2626
_noResult: v4()
27-
};
27+
});
2828

2929
return debounceFn(() => {
3030
const value = factoryRef.current(actualNoResult);

0 commit comments

Comments
 (0)