Hooks for web components
npm install starcounter-jack-haunted

React's Hooks API but for standard web components and lit-html or hyperHTML.
š Read the Docs š
``html
`
More example integrations can be found in this gist.
Haunted supports the same API as React Hooks. The hope is that by doing so you can reuse hooks available on npm simply by aliasing package names in your bundler's config.
Currently Haunted supports the following hooks:
- useCallback
- useContext
- useController
- useEffect
- useLayoutEffect
- useMemo
- useReducer
- useRef
- useState
`ts
// Or another renderer, see Guides
type Renderer = (element: Element) => TemplateResult;
interface Options {
baseElement: HTMLElement;
observedAttributes: string[];
useShadowDOM: boolean
}
declare function component(
renderer: Renderer,
options: Options
): Element;
declare function component
renderer: Renderer,
baseElement: BaseElement,
options: Options
): Element
declare function virtual(renderer: Renderer): Directive
``
BSD-2-Clause