Skip to content

wrapStaticHook

Александр edited this page Jan 17, 2023 · 1 revision
export function wrapStaticHook<T extends (...args: any[]) => any>(hook: T): T

Wraps the original hook. Allows you to use it in afc components.

The return value does not change (static hook).

import { afc, wrapStaticHook } from 'react-afc'
import { externalHook } from './hooks'

const staticHook = wrapStaticHook(externalHook)

function Component(props) {
  const value = staticHook('Any static property')

  return () => (
    <p>Static value: {value}</p>
  )
}

export default afc(Component)
Clone this wiki locally