0.1.1 • Published 21 days ago

use-signals v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
21 days ago

use-signals

CI npm size discord

An experimental React hook for TC39 signals

Install

npm install use-signals

Usage

import { Signal, useSignal } from 'use-signals';

const counter = new Signal.State(0);

const Counter = () => {
  const count = useSignal(counter);
  const inc = () => counter.set(counter.get() + 1);
  return (
    <>
      <div>Count: {count}</div>
      <button type="button" onClick={inc}>
        +1
      </button>
    </>
  );
};

Examples

The examples folder contains working examples. You can run one of them with

PORT=8080 yarn run examples:01_counter

and open http://localhost:8080 in your web browser.

You can also try them in codesandbox.io: 01 02

Tweets

0.1.1

21 days ago

0.1.0

23 days ago

0.0.3

1 month ago

0.0.2

1 month ago

0.0.1

1 month ago

0.0.0

1 month ago