preact
- Version 10.25.4
- Published
- 1.43 MB
- No dependencies
- MIT license
Install
npm i preact
yarn add preact
pnpm add preact
Overview
Fast 3kb React-compatible Virtual DOM library.
Index
Variables
Functions
Classes
Interfaces
Type Aliases
Namespaces
Variables
Functions
function cloneElement
cloneElement: { (vnode: VNode<any>, props?: any, ...children: ComponentChildren[]): VNode<any>; <P>(vnode: VNode<P>, props?: any, ...children: ComponentChildren[]): VNode<P>;};
function createContext
createContext: <T>(defaultValue: T) => Context<T>;
function createElement
createElement: typeof createElement;
function createRef
createRef: <T = any>() => RefObject<T>;
function h
h: typeof h;
function hydrate
hydrate: (vnode: ComponentChild, parent: ContainerNode) => void;
function isValidElement
isValidElement: (vnode: any) => vnode is VNode<{}>;
function render
render: { (vnode: ComponentChild, parent: ContainerNode): void; ( vnode: ComponentChild, parent: ContainerNode, replaceNode?: Element | Text ): void;};
Deprecated
Will be removed in v11.
Replacement Preact 10+ implementation can be found here: https://gist.github.com/developit/f4c67a2ede71dc2fab7f357f39cff28c
function toChildArray
toChildArray: (children: ComponentChildren) => Array<VNode | string | number>;
Classes
class Component
abstract class Component<P, S> {}
constructor
constructor(props?: {}, context?: any);
property base
base?: Element | Text;
property context
context: any;
property contextType
static contextType?: Context<any>;
property defaultProps
static defaultProps?: any;
property displayName
static displayName?: string;
property props
props: Readonly<Attributes & { children?: ComponentChildren; ref?: Ref<any> }>;
property state
state: Readonly<S>;
method forceUpdate
forceUpdate: (callback?: () => void) => void;
method getDerivedStateFromError
static getDerivedStateFromError: (error: any) => object | null;
method getDerivedStateFromProps
static getDerivedStateFromProps: ( props: Readonly<object>, state: Readonly<object>) => object | null;
method render
abstract render: ( props?: RenderableProps<P>, state?: Readonly<S>, context?: any) => ComponentChildren;
method setState
setState: <K extends keyof S>( state: | (( prevState: Readonly<S>, props: Readonly<P> ) => Pick<S, K> | Partial<S> | null) | Pick<S, K> | Partial<S>, callback?: () => void) => void;
Interfaces
interface Attributes
interface Attributes {}
interface ClassAttributes
interface ClassAttributes<T> extends Attributes {}
property ref
ref?: Ref<T>;
interface Component
interface Component<P = {}, S = {}> {}
method componentDidCatch
componentDidCatch: (error: any, errorInfo: ErrorInfo) => void;
method componentDidMount
componentDidMount: () => void;
method componentDidUpdate
componentDidUpdate: ( previousProps: Readonly<P>, previousState: Readonly<S>, snapshot: any) => void;
method componentWillMount
componentWillMount: () => void;
method componentWillReceiveProps
componentWillReceiveProps: (nextProps: Readonly<P>, nextContext: any) => void;
method componentWillUnmount
componentWillUnmount: () => void;
method componentWillUpdate
componentWillUpdate: ( nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any) => void;
method getChildContext
getChildContext: () => object;
method getSnapshotBeforeUpdate
getSnapshotBeforeUpdate: (oldProps: Readonly<P>, oldState: Readonly<S>) => any;
method shouldComponentUpdate
shouldComponentUpdate: ( nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any) => boolean;
interface ComponentClass
interface ComponentClass<P = {}, S = {}> {}
property contextType
contextType?: Context<any>;
property defaultProps
defaultProps?: Partial<P>;
property displayName
displayName?: string;
method getDerivedStateFromError
getDerivedStateFromError: (error: any) => Partial<S> | null;
method getDerivedStateFromProps
getDerivedStateFromProps: ( props: Readonly<P>, state: Readonly<S>) => Partial<S> | null;
construct signature
new (props: P, context?: any): Component<P, S>;
interface ComponentConstructor
interface ComponentConstructor<P = {}, S = {}> extends ComponentClass<P, S> {}
interface Consumer
interface Consumer<T> extends FunctionComponent<{ children: (value: T) => ComponentChildren; }> {}
interface ContainerNode
interface ContainerNode {}
property childNodes
readonly childNodes: ArrayLike<ContainerNode>;
property firstChild
readonly firstChild: ContainerNode | null;
property nodeType
readonly nodeType: number;
property parentNode
readonly parentNode: ContainerNode | null;
method appendChild
appendChild: (node: ContainerNode) => ContainerNode;
method contains
contains: (other: ContainerNode | null) => boolean;
method insertBefore
insertBefore: ( node: ContainerNode, child: ContainerNode | null) => ContainerNode;
method removeChild
removeChild: (child: ContainerNode) => ContainerNode;
interface Context
interface Context<T> {}
property Consumer
Consumer: Consumer<T>;
property displayName
displayName?: string;
property Provider
Provider: Provider<T>;
interface ErrorInfo
interface ErrorInfo {}
property componentStack
componentStack?: string;
interface FunctionalComponent
interface FunctionalComponent<P = {}> extends FunctionComponent<P> {}
interface FunctionComponent
interface FunctionComponent<P = {}> {}
property defaultProps
defaultProps?: Partial<P> | undefined;
property displayName
displayName?: string;
call signature
(props: RenderableProps<P>, context?: any): ComponentChildren;
interface Options
interface Options {}
Global options for preact
method attr
attr: (name: string, value: any) => string | void;
Customize attribute serialization when a precompiled JSX transform is used.
method debounceRendering
debounceRendering: (cb: () => void) => void;
method diffed
diffed: (vnode: VNode) => void;
Attach a hook that is invoked after a vnode has rendered.
method event
event: (e: Event) => any;
method requestAnimationFrame
requestAnimationFrame: (callback: () => void) => void;
method unmount
unmount: (vnode: VNode) => void;
Attach a hook that is invoked immediately before a vnode is unmounted.
method useDebugValue
useDebugValue: (value: string | number) => void;
method vnode
vnode: (vnode: VNode) => void;
Attach a hook that is invoked whenever a VNode is created.
interface PreactConsumer
interface PreactConsumer<T> extends Consumer<T> {}
interface PreactContext
interface PreactContext<T> extends Context<T> {}
interface PreactDOMAttributes
interface PreactDOMAttributes {}
property children
children?: ComponentChildren;
property dangerouslySetInnerHTML
dangerouslySetInnerHTML?: { __html: string;};
interface PreactProvider
interface PreactProvider<T> extends Provider<T> {}
interface Provider
interface Provider<T> extends FunctionComponent<{ value: T; children?: ComponentChildren; }> {}
interface VNode
interface VNode<P = {}> {}
property endTime
endTime?: number;
The time that the rendering of this
vnode
was completed. Will only be set when the devtools are attached. Default value:-1
property key
key: Key;
property props
props: P & { children: ComponentChildren };
property ref
ref?: Ref<any> | null;
ref is not guaranteed by React.ReactElement, for compatibility reasons with popular react libs we define it as optional too
property startTime
startTime?: number;
The time this
vnode
started rendering. Will only be set when the devtools are attached. Default value:0
property type
type: ComponentType<P> | string;
Type Aliases
type AnyComponent
type AnyComponent<P = {}, S = {}> = | FunctionComponent<P> | ComponentConstructor<P, S>;
type ComponentChild
type ComponentChild = | VNode<any> | object | string | number | bigint | boolean | null | undefined;
type ComponentChildren
type ComponentChildren = ComponentChild[] | ComponentChild;
type ComponentFactory
type ComponentFactory<P = {}> = ComponentType<P>;
type ComponentProps
type ComponentProps< C extends ComponentType<any> | keyof JSXInternal.IntrinsicElements> = C extends ComponentType<infer P> ? P : C extends keyof JSXInternal.IntrinsicElements ? JSXInternal.IntrinsicElements[C] : never;
type ComponentType
type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
type ContextType
type ContextType<C extends Context<any>> = C extends Context<infer T> ? T : never;
type Key
type Key = string | number | any;
type Ref
type Ref<T> = RefObject<T> | RefCallback<T> | null;
type RefCallback
type RefCallback<T> = (instance: T | null) => void;
type RefObject
type RefObject<T> = { current: T | null };
type RenderableProps
type RenderableProps<P, RefType = any> = P & Readonly<Attributes & { children?: ComponentChildren; ref?: Ref<RefType> }>;
Namespaces
namespace createElement
namespace createElement {}
namespace h
namespace h {}
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (46)
- @actions/github
- @actions/glob
- @babel/core
- @babel/plugin-proposal-object-rest-spread
- @babel/plugin-transform-react-jsx
- @babel/plugin-transform-react-jsx-source
- @babel/preset-env
- @babel/register
- @biomejs/biome
- @types/chai
- @types/mocha
- @types/node
- @types/sinon
- babel-plugin-istanbul
- babel-plugin-transform-async-to-promises
- babel-plugin-transform-rename-properties
- chai
- check-export-map
- core-js
- coveralls
- cross-env
- errorstacks
- esbuild
- husky
- karma
- karma-chai-sinon
- karma-chrome-launcher
- karma-coverage
- karma-esbuild
- karma-mocha
- karma-mocha-reporter
- karma-sinon
- karma-sourcemap-loader
- kolorist
- microbundle
- mocha
- npm-merge-driver-install
- npm-run-all2
- oxlint
- preact-render-to-string
- prop-types
- sade
- sinon
- sinon-chai
- typescript
- undici
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/preact
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/preact)
- HTML<a href="https://www.jsdocs.io/package/preact"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 5255 ms. - Missing or incorrect documentation? Open an issue for this package.