React Pair Reference
🖇️ Util to help with the paired hook pattern.
Usage
📦 Node
Install react-pair
as a dependency:
Import it and use it:
🦕 Deno
Import react-pair
using the npm:
prefix, and use it directly:
🌎 Browser
Import react-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<Hook>
Paired component properties (just children with the paired hook render function).
Type parameters
Type parameter |
---|
Hook extends Function |
Type declaration
Member | Type | Description |
---|---|---|
children | PairedRenderFunction <Hook > | Children has to be a function, and the argument is the paired hook. |
PairedRenderFunction<Hook>
Function that receives the paired hook and must return a ReactElement
.
Type parameters
Type parameter |
---|
Hook extends Function |
Other
pair()
Creates a component with a function children that has the given hook in context.
Type parameters
Type parameter |
---|
Hook extends Function |
Parameters
Parameter | Type | Description |
---|---|---|
hook | Hook | Hook to be paired. |
Returns
FunctionComponent
<PairedComponentProperties
<Hook
>>
& object
Component that expects a function as children with the paired hook.
Example
preact-pair
Internal
PairedComponentProperties<Hook>
Paired component properties (just children with the paired hook render function).
Type parameters
Type parameter |
---|
Hook extends Function |
Type declaration
Member | Type | Description |
---|---|---|
children | PairedRenderFunction <Hook > | Children has to be a function, and the argument is the paired hook. |
PairedRenderFunction<Hook>
Function that receives the paired hook and must return a VNode
.
Type parameters
Type parameter |
---|
Hook extends Function |
Other
pair()
Creates a component with a function children that has the given hook in context.
Type parameters
Type parameter |
---|
Hook extends Function |
Parameters
Parameter | Type | Description |
---|---|---|
hook | Hook | Hook to be paired. |
Returns
FunctionComponent
<PairedComponentProperties
<Hook
>>
& object
Component that expects a function as children with the paired hook.