import { useState } from 'react'; import { dequal } from '../lib/dequal'; export function useStableValue(value: TValue) { const [stableValue, setStableValue] = useState(() => value); if (!dequal(stableValue, value)) { setStableValue(value); } return stableValue; }