Skip to content
This repository was archived by the owner on Dec 30, 2022. It is now read-only.

Commit d1f53ae

Browse files
authored
1 parent 7366327 commit d1f53ae

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import { useEffect, useState } from 'react';
1+
import { useState } from 'react';
22

33
import { dequal } from '../lib/dequal';
44

55
export function useStableValue<TValue>(value: TValue) {
66
const [stableValue, setStableValue] = useState<TValue>(() => value);
77

8-
useEffect(() => {
9-
if (!dequal(stableValue, value)) {
10-
setStableValue(value);
11-
}
12-
// eslint-disable-next-line react-hooks/exhaustive-deps
13-
}, [value]);
8+
if (!dequal(stableValue, value)) {
9+
setStableValue(value);
10+
}
1411

1512
return stableValue;
1613
}

0 commit comments

Comments
 (0)