hypereact
A lightweight React state management which inspired on hyperapp
Hypereact in action
- Todo App: https://codesandbox.io/s/23r32ynkxj
Samples
Declare store
;const initialState = todos: {} ids: text: "";;
Declare an action
Add.js
;;; const dispatch = { // generate random id const id = ; return ;}; dispatch;
Declare a view
TodoForm.js
;;;; const render = <form onSubmit= { e; ; } > <input type="text" value=text onChange= placeholder="Enter new todo" /> </form>; // specified dependency actions actions: Add ChangeText // map state to props text // map dispatch to props add changeText render;
ChangeText.js
;; const dispatch = ; dispatch;
State change subscription
;const unsubscribe = ; ;
Dispatch action from outside view
;; ;
Dispatch action from other action
// ActionA.js;;; const dispatch = { ; ;}; actions: ActionB ActionC dispatch;