@store-unit/react
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

@store-unit/react

A react integration for store-unit

Getting Started

Install

npm install @store-unit/react

Usage

import { Store } from 'store-unit';
import { useStore } from '@store-unit/react';

const themeStore = new Store({ isLight: true });

export function Component() {
  const value = useStore(themeStore);
  return (
    <div style={{ background: value.isLight ? 'white' : 'black' }}>
      <button
        onClick={() => {
          themeStore.setState({ isLight: !value.isLight });
        }}
      >
        Toggle theme
      </button>
    </div>
  );
}

Readme

Keywords

Package Sidebar

Install

npm i @store-unit/react

Weekly Downloads

102

Version

1.0.4

License

MIT

Unpacked Size

37.6 kB

Total Files

18

Last publish

Collaborators

  • everdimension