Skip to content

Commit

Permalink
Merge branch 'experimental' of https://github.com/uidotdev/usehooks i…
Browse files Browse the repository at this point in the history
…nto experimental
  • Loading branch information
tylermcginnis committed Oct 9, 2023
2 parents ce0aedc + 6ffa8e7 commit a0a0cff
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 11 deletions.
76 changes: 68 additions & 8 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,34 @@ declare module "@uidotdev/usehooks" {
(value: string) => Promise<void>
];

export function useContinuousRetry(
callback: () => any,
interval?: number,
options?: {
maxRetries?: number
}): boolean;

export function useCountdown(endTime: number, options: {
interval: number,
onComplete: () => any,
onTick: () => any
}): number;

export function useCounter(
startingValue?: number,
options?: {
min?: number;
max?: number;
}
): [
number,
{
increment: () => void;
decrement: () => void;
set: (nextCount: number) => void;
reset: () => void;
}
];
number,
{
increment: () => void;
decrement: () => void;
set: (nextCount: number) => void;
reset: () => void;
}
];

export function useDebounce<T>(value: T, delay: number): T;

Expand All @@ -153,8 +166,25 @@ declare module "@uidotdev/usehooks" {

export function useDocumentTitle(title: string): void;

export function useEventListener(
target: React.MutableRefObject<Element> | Element,
eventName: string,
handler: (Event) => any,
options?: {
capture?: boolean,
passive?: boolean,
once?: boolean
}): void;

export function useFavicon(url: string): void;

export function useFetch(
url: string,
options?: {}): {
error: Error | undefined,
data: any | undefined
}

export function useGeolocation(options?: PositionOptions): GeolocationState;

export function useHistoryState<T>(initialPresent?: T): HistoryState<T>;
Expand All @@ -170,10 +200,29 @@ declare module "@uidotdev/usehooks" {
options?: IntersectionObserverInit
): [React.MutableRefObject<T>, IntersectionObserverEntry | null];

export function useInterval(cb: () => any, ms: number): () => void;

export function useIntervalWhen(
cb: () => any,
options: {
ms: number,
when: boolean,
startImmediately?: boolean
}): () => void;

export function useIsClient(): boolean;

export function useIsFirstRender(): boolean;

export function useKeyPress(
key: string,
cb: (Event) => any,
options?: {
event?: string,
target?: Element | Window,
eventOptions?: {}
}): void;

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

export function useLocalStorage<T>(
Expand All @@ -183,6 +232,8 @@ declare module "@uidotdev/usehooks" {

export function useLockBodyScroll(): void;

export function useLogger(name: string, ...rest: any[]): void;

export function useLongPress(
callback: (e: Event) => void,
options?: LongPressOptions
Expand Down Expand Up @@ -214,12 +265,19 @@ declare module "@uidotdev/usehooks" {
type: string;
};

export function usePageLeave(cb: () => any): void;

export function usePreferredLanguage(): string;

export function usePrevious<T>(newValue: T): T;

export function useQueue<T>(initialValue?: T[]): CustomQueue<T>;

export function useRandomInterval(cb: () => any, options: {
minDelay: number,
maxDelay: number
}): () => void;

export function useRenderCount(): number;

export function useRenderInfo(name?: string): RenderInfo | undefined;
Expand All @@ -242,6 +300,8 @@ declare module "@uidotdev/usehooks" {

export function useThrottle<T>(value: T, delay: number): T;

export function useTimeout(cb: () => any, ms: number): () => void;

export function useToggle(
initialValue?: boolean
): [boolean, (newValue?: boolean) => void];
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uidotdev/usehooks",
"version": "2.1.1-experimental.1",
"version": "2.3.1-experimental.1",
"description": "A collection of modern, server-safe React hooks – from the ui.dev team",
"type": "module",
"repository": "uidotdev/usehooks",
Expand Down

0 comments on commit a0a0cff

Please sign in to comment.