0.4.0 • Published 5 months ago

@hanabira/store v0.4.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

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>
  );
};
0.3.0

5 months ago

0.4.0

5 months ago

0.2.0

5 months ago

0.1.0

5 months ago

0.0.0

5 months ago