Skip to content

Commit ce0aedc

Browse files
committed
Make some return values referentially stable
2 parents 47a11b9 + cd819c9 commit ce0aedc

File tree

10 files changed

+222
-203
lines changed

10 files changed

+222
-203
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Compatible with React v18.0.0+.
3030
- [useIsClient](https://usehooks.com/useisclient)
3131
- [useIsFirstRender](https://usehooks.com/useisfirstrender)
3232
- [useList](https://usehooks.com/uselist)
33+
- [useLocalStorage](https://usehooks.com/uselocalstorage)
3334
- [useLockBodyScroll](https://usehooks.com/uselockbodyscroll)
3435
- [useLongPress](https://usehooks.com/uselongpress)
3536
- [useMap](https://usehooks.com/usemap)
@@ -45,6 +46,7 @@ Compatible with React v18.0.0+.
4546
- [useRenderCount](https://usehooks.com/userendercount)
4647
- [useRenderInfo](https://usehooks.com/userenderinfo)
4748
- [useScript](https://usehooks.com/usescript)
49+
- [useSessionStorage](https://usehooks.com/usesessionstorage)
4850
- [useSet](https://usehooks.com/useset)
4951
- [useThrottle](https://usehooks.com/usethrottle)
5052
- [useToggle](https://usehooks.com/usetoggle)
@@ -67,9 +69,7 @@ Compatible with React v18.0.0+.
6769
- [useInterval](https://usehooks.com/useinterval)
6870
- [useIntervalWhen](https://usehooks.com/useintervalwhen)
6971
- [useKeyPress](https://usehooks.com/usekeypress)
70-
- [useLocalStorage](https://usehooks.com/uselocalstorage)
7172
- [useLogger](https://usehooks.com/uselogger)
7273
- [usePageLeave](https://usehooks.com/usepageleave)
7374
- [useRandomInterval](https://usehooks.com/userandominterval)
74-
- [useSessionStorage](https://usehooks.com/usesessionstorage)
7575
- [useTimeout](https://usehooks.com/usetimeout)

index.d.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export type CustomQueue<T> = {
8282
first: T | undefined;
8383
last: T | undefined;
8484
size: number;
85+
queue: T[];
8586
};
8687

8788
export type RenderInfo = {
@@ -165,16 +166,21 @@ declare module "@uidotdev/usehooks" {
165166

166167
export function useIdle(ms?: number): boolean;
167168

168-
export function useIntersectionObserver(
169+
export function useIntersectionObserver<T extends Element>(
169170
options?: IntersectionObserverInit
170-
): [React.MutableRefObject<Element>, IntersectionObserverEntry | null];
171+
): [React.MutableRefObject<T>, IntersectionObserverEntry | null];
171172

172173
export function useIsClient(): boolean;
173174

174175
export function useIsFirstRender(): boolean;
175176

176177
export function useList<T>(defaultList?: T[]): [T[], CustomList<T>];
177178

179+
export function useLocalStorage<T>(
180+
key: string,
181+
initialValue?: T
182+
): [T, React.Dispatch<React.SetStateAction<T>>];
183+
178184
export function useLockBodyScroll(): void;
179185

180186
export function useLongPress(
@@ -225,6 +231,11 @@ declare module "@uidotdev/usehooks" {
225231
}
226232
): "idle" | "loading" | "ready" | "error";
227233

234+
export function useSessionStorage<T>(
235+
key: string,
236+
initialValue: T
237+
): [T, React.Dispatch<React.SetStateAction<T>>];
238+
228239
export function useSet<T>(values?: T[]): Set<T>;
229240

230241
export function useSpeech(text: string, options?: SpeechOptions): SpeechState;

0 commit comments

Comments
 (0)