Sha256: 2664133ecaa5b9091e9cc0bf1880b233da7d0ba7b422d8a014a142822b550b9d

Contents?: true

Size: 1.73 KB

Versions: 66

Compression:

Stored size: 1.73 KB

Contents

import {
	Component as PreactComponent,
	PreactContext
} from '../../src/internal';
import { Reducer } from '.';

export { PreactContext };

/**
 * The type of arguments passed to a Hook function. While this type is not
 * strictly necessary, they are given a type name to make it easier to read
 * the following types and trace the flow of data.
 */
export type HookArgs = any;

/**
 * The return type of a Hook function. While this type is not
 * strictly necessary, they are given a type name to make it easier to read
 * the following types and trace the flow of data.
 */
export type HookReturnValue = any;

/** The public function a user invokes to use a Hook */
export type Hook = (...args: HookArgs[]) => HookReturnValue;

// Hook tracking

export interface ComponentHooks {
	/** The list of hooks a component uses */
	_list: HookState[];
	/** List of Effects to be invoked after the next frame is rendered */
	_pendingEffects: EffectHookState[];
}

export interface Component extends PreactComponent<any, any> {
	__hooks?: ComponentHooks;
}

export type HookState =
	| EffectHookState
	| MemoHookState
	| ReducerHookState
	| ContextHookState
	| ErrorBoundaryHookState;

export type Effect = () => void | Cleanup;
export type Cleanup = () => void;

export interface EffectHookState {
	_value?: Effect;
	_args?: any[];
	_cleanup?: Cleanup | void;
}

export interface MemoHookState {
	_value?: any;
	_args?: any[];
	_factory?: () => any;
}

export interface ReducerHookState {
	_value?: any;
	_component?: Component;
	_reducer?: Reducer<any, any>;
}

export interface ContextHookState {
	/** Whether this hooks as subscribed to updates yet */
	_value?: boolean;
	_context?: PreactContext;
}

export interface ErrorBoundaryHookState {
	_value?: (error: any) => void;
}

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
isomorfeus-preact-10.6.47 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.46 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.45 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.44 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.43 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.42 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.41 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.40 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.39 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.38 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.37 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.36 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.35 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.34 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.33 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.32 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.31 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.30 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.29 node_modules/preact/hooks/src/internal.d.ts
isomorfeus-preact-10.6.28 node_modules/preact/hooks/src/internal.d.ts