Preact Pair Reference
ποΈ Util to help with the paired hook pattern.
Usage
π¦ Node
Install preact-pair
as a dependency:
Import it and use it:
π¦ Deno
Import preact-pair
using the npm:
prefix, and use it directly:
π Browser
Import preact-pair
using esm.sh, and use it directly:
Useful links
- π Documentation: TypeDoc generated documentation.
- β³ Changelog: List of changes between versions.
- β Tests Coverage: Coveralls page with tests coverage.
Internal
PairedComponentProperties
Ζ¬ PairedComponentProperties<Hook
>: Object
Paired component properties (just children with the paired hook render function).
Type parameters
Name | Type |
---|---|
Hook | extends Function |
Type declaration
Name | Type | Description |
---|---|---|
children | PairedRenderFunction <Hook > | Children has to be a function, and the argument is the paired hook. |
PairedRenderFunction
Ζ¬ PairedRenderFunction<Hook
>: Unary
<Hook
, ReturnType
<typeof
h
>>
Function that receives the paired hook and must return a VNode
.
Type parameters
Name | Type |
---|---|
Hook | extends Function |
Other
pair
βΈ pair<Hook
>(hook
):
FunctionComponent
<PairedComponentProperties
<Hook
>>
& { displayName
: `paired(${Hook[βnameβ]})` }
Creates a component with a function children that has the given hook in context.
Type parameters
Name | Type |
---|---|
Hook | extends Function |
Parameters
Name | Type | Description |
---|---|---|
hook | Hook | Hook to be paired. |
Returns
FunctionComponent
<PairedComponentProperties
<Hook
>>
& { displayName
: `paired(${Hook[βnameβ]})` }
Component that expects a function as children with the paired hook.
Example