export function wrapDynamicHook<T extends (...args: any[]) => any>(hook: T): ((argsGetter: () => Parameters<T>) => () => ReturnType<T>)
Wraps the original hook. Allows you to use it in afc components.
afc
The return value is calculated every render (dynamic hook).
import { afc, wrapDynamicHook } from 'react-afc' import { externalHook } from './hooks' const dynamicHook = wrapDynamicHook(externalHook) function Component(props) { let dynamicArgument = 5 const getDynResult = dynamicHook(() => [dynamicArgument]) return () => ( <p>Dynamic value: {getDynResult()}</p> ) } export default afc(Component)
There was an error while loading. Please reload this page.
Component
Lifecycle
State
Redux
Other