React-Hookz
React Global Hookz, a simple global state for React with the Hooks API in less than 1kb written in TypeScript
Table of Contents
Installation
npm install react-hookz
Usage
Minimal example:
Actions
const addToCounter = { const counter = storestatecounter + amount; store;};
HOC
;; ; const initialState: GlobalState = counter: 1; const useReactHookz = ;const connect = { return { let state actions = ; let _props = ...props state actions ; return <Component ..._props />; };}; ;
Component
;; interface Props state: any; actions: any; const Counter: React.FC<Props> = { const state actions = props; return <div className="Counter"> <p> FC Counter: statecounter </p> <button type="button" onClick= actions> +1 to global </button> </div> ;}; Counter;