0.1.0-alpha.0 • Published 2 years ago

actus-react v0.1.0-alpha.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

actus-react

React bindings for actus

npm version

Included and preconfigured plugins

Install

npm install actus-react

Examples

Usage

First create a store

// store.js

import { createStore } from "actus-react";

export const { actions, useSelector } = createStore({
  state: {
    number: 0,
  },
});

Then use actions and useSelector() in your components, that's it!

// App.js

import { actions, useSelector } from "./store.js";

export default function App() {
  const number = useSelector((state) => state.number);

  return (
    <>
      <h1>{number}</h1>
      <button onClick={actions.number.increment}>+</button>
      <button onClick={actions.number.decrement}>-</button>
    </>
  );
}