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

0.4.0 • Public • Published

Hana Store

Hana Store is a simple, lightweight and easy to use state management library for Hana. It focuses on developer experience and ease of use. It requires no boilerplate, no configuration, and no extra dependencies to get started.

Example

import { createStore } from '@hanabira/store';

/**
 * Add default options based on your needs.
 * This is optional.
 */
createStore({
  state: {
    count: 0,
  },
  reducers: {
    increment: (state, payload = null) => {
      return {
        count: state.count + 1,
      };
    },
  },
});

In your components:

import { useStore, useReducer } from '@hanabira/store';

/**
 * Use the store in your components.
 */
const Counter = () => {
  const [count, setCount] = useStore('count');
  const increment = useReducer('increment');

  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => increment()}>Increment</button>
    </div>
  );
};

Readme

Keywords

none

Package Sidebar

Install

npm i @hanabira/store

Weekly Downloads

5

Version

0.4.0

License

MIT

Unpacked Size

36.7 kB

Total Files

5

Last publish

Collaborators

  • mychi