Skip to content

Commit

Permalink
compat: Use Ref and RefObject types from core in hooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbrieiev committed Jun 1, 2024
1 parent 11c9534 commit 92fd386
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions hooks/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ErrorInfo, PreactContext, Ref as PreactRef } from '../..';
import { ErrorInfo, PreactContext, Ref, RefObject } from '../..';

type Inputs = ReadonlyArray<unknown>;

Expand Down Expand Up @@ -52,9 +52,6 @@ export function useReducer<S, A, I>(

/** @deprecated Use the `Ref` type instead. */
type PropRef<T> = MutableRef<T>;
interface Ref<T> {
readonly current: T | null;
}

interface MutableRef<T> {
current: T;
Expand All @@ -70,7 +67,7 @@ interface MutableRef<T> {
* @param initialValue the initial value to store in the ref object
*/
export function useRef<T>(initialValue: T): MutableRef<T>;
export function useRef<T>(initialValue: T | null): Ref<T>;
export function useRef<T>(initialValue: T | null): RefObject<T>;
export function useRef<T = undefined>(): MutableRef<T | undefined>;

type EffectCallback = () => void | (() => void);
Expand All @@ -92,7 +89,7 @@ type CreateHandle = () => object;
* @param inputs If present, effect will only activate if the values in the list change (using ===).
*/
export function useImperativeHandle<T, R extends T>(
ref: PreactRef<T>,
ref: Ref<T>,
create: () => R,
inputs?: Inputs
): void;
Expand Down

0 comments on commit 92fd386

Please sign in to comment.