1.0.3 • Published 6 years ago
reaktion v1.0.3
Use the same API as useState React hook for transverse state management :muscle:
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>
);
};