1.0.4 • Published 6 months ago

@store-unit/react v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@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>
  );
}
1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago