All Projects → matthewp → Haunted

matthewp / Haunted

Licence: bsd-2-clause
React's Hooks API implemented for web components 👻

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
HTML
75241 projects

Projects that are alternatives of or similar to Haunted

React-Combine-Provider
combine react providers in ease
Stars: ✭ 29 (-98.68%)
Mutual labels:  hooks, react-hooks
Beautiful React Hooks
🔥 A collection of beautiful and (hopefully) useful React hooks to speed-up your components and hooks development 🔥
Stars: ✭ 5,242 (+138.6%)
Mutual labels:  hooks, react-hooks
Constate
React Context + State
Stars: ✭ 3,519 (+60.17%)
Mutual labels:  hooks, react-hooks
learn-react-typescript
Learning React contents with TypeScript (Hooks, Redux)
Stars: ✭ 15 (-99.32%)
Mutual labels:  hooks, react-hooks
Awesome React Hooks
Awesome React Hooks
Stars: ✭ 7,616 (+246.65%)
Mutual labels:  hooks, react-hooks
bui
‹b› Web components for creating applications – built by Blackstone Publishing using lit-html and lit-element
Stars: ✭ 29 (-98.68%)
Mutual labels:  web-components, lit-html
Easy Peasy
Vegetarian friendly state for React
Stars: ✭ 4,525 (+105.96%)
Mutual labels:  hooks, react-hooks
max-todos
A basic Todo app developed in React.
Stars: ✭ 19 (-99.14%)
Mutual labels:  hooks, react-hooks
Formik
Build forms in React, without the tears 😭
Stars: ✭ 29,047 (+1222.12%)
Mutual labels:  hooks, react-hooks
Atomico
Atomico a micro-library for creating webcomponents using only functions, hooks and virtual-dom.
Stars: ✭ 481 (-78.11%)
Mutual labels:  hooks, web-components
react-europe-2019
Slides and demo app from my keynote
Stars: ✭ 29 (-98.68%)
Mutual labels:  hooks, react-hooks
Graphql Hooks
🎣 Minimal hooks-first GraphQL client
Stars: ✭ 1,610 (-26.72%)
Mutual labels:  hooks, react-hooks
react-daterange-picker
A react date range picker to using @material-ui. Live Demo: https://flippingbitss.github.io/react-daterange-picker/
Stars: ✭ 85 (-96.13%)
Mutual labels:  hooks, react-hooks
atomic-state
A decentralized state management library for React
Stars: ✭ 54 (-97.54%)
Mutual labels:  hooks, react-hooks
reason-hooks-lib
A set of reusable ReasonReact hooks.
Stars: ✭ 31 (-98.59%)
Mutual labels:  hooks, react-hooks
React Hook Form
📋 React Hooks for form state management and validation (Web + React Native)
Stars: ✭ 24,831 (+1030.22%)
Mutual labels:  hooks, react-hooks
use-metamask
a custom React Hook to manage Metamask in Ethereum ĐApp projects
Stars: ✭ 131 (-94.04%)
Mutual labels:  hooks, react-hooks
use-window-focus
React Hook to check if window is focused
Stars: ✭ 19 (-99.14%)
Mutual labels:  hooks, react-hooks
The Platform
Web. Components. 😂
Stars: ✭ 4,355 (+98.22%)
Mutual labels:  hooks, react-hooks
Wired Elements
Collection of custom elements that appear hand drawn. Great for wireframes or a fun look.
Stars: ✭ 8,848 (+302.73%)
Mutual labels:  web-components, lit-html

Haunted 🦇 🎃

npm npm

React's Hooks API but for standard web components and lit-html or hyperHTML.

📚 Read the Docs 📖

<html lang="en">
  <my-counter></my-counter>

  <script type="module">
    import { html } from 'https://unpkg.com/lit-html/lit-html.js';
    import { component, useState } from 'https://unpkg.com/haunted/haunted.js';

    function Counter() {
      const [count, setCount] = useState(0);

      return html`
        <div id="count">${count}</div>
        <button type="button" @click=${() => setCount(count + 1)}>
          Increment
        </button>
      `;
    }

    customElements.define('my-counter', component(Counter));
  </script>
</html>

More example integrations can be found in this gist.

Hooks

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:

Function Signatures

// 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<BaseElement = HTMLElement>(
  renderer: Renderer,
  baseElement: BaseElement,
  options: Options
): Element

declare function virtual(renderer: Renderer): Directive

License

BSD-2-Clause

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].