reaktion

1.0.3 • Public • Published

Build Status Coverage Status License: MIT

Use the same API as useState React hook for transverse state management 💪

Usage

Installation

Make sure you run in a project using React v16.7 or higher

$ yarn add reaktion

In your code

import { Reaktion, useStore } from "reaktion";
 
const Hello = () => {
  /**
   * The first element is the state node
   * The second element is a function that mutates only that node
   **/
  const [name, setName] = useStore("name");
 
  return <button onClick={() => setName("Marvin")}>Hello {name}</button>;
};
 
/**
 * Initial transverse node
 **/
const initialState = { name: "World" };
 
const App = () => {
  /**
   * Reaktion is the state provider. It must be placed at a top level of your app
   **/
  return (
    <Reaktion initialState={initialState}>
      <Hello />
    </Reaktion>
  );
};

Readme

Keywords

Package Sidebar

Install

npm i reaktion

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

6.89 kB

Total Files

5

Last publish

Collaborators

  • skahrz