enhook
Enable react/preact/∀ hooks for regular functions.
let countFrom =
Enhook turns any function into reactive function with enabled hooks for a given framework. The framework is by default detected from the list:
In case of ES modules autodetection is not available (until import.meta.resolve()
or await import()
is available), you have to manually indicate framework to use.
enhook // or enhook.use(React, ReactDOM) // now enhook uses preact with as baselet fn =
API
fn = enhook(fn, { passive=false }?)
Create function wrapper, allowing hooks in function body. passive
option may define if function must be reactive.
let passiveFn =
fn.unhook()
Teardown enhooked function. This will dispose all useEffect
s. Any subsequent calls to that function will throw an error.
See also
- unihooks - unified all-framework essential hooks collection.
License
MIT
HK