hyper-redux
v0.0.5
Published
hyper app style react/redux
Downloads
5
Readme
hyper-redux
HyperApp style redux
For those who need to use react and redux but want something simple
- No more switch statments or action objects
- Fully supports redux debugger with time travel ect.
- Can be strongly typed with TypeScript
- Can use context to access state and actions in nested components
Install
npm install hyper-redux
Example
import * as React from 'react';
import { app } from 'hyper-redux';
const initalState: 0;
const actionsMap = {
increment: delta => state => state + delta,
decrement: delta => state => state - delta,
incrementDelayed: delta => (state, actions) => {
setTimeout(actions.increment, 1000, delta);
return state;
}
};
function view(state, actions ) {
return (
<div>
<p> Clicked: {state} times </p>
<button onClick={() => actions.increment(1)}>+</button>
<button onClick={() => actions.decrement(1)}>-</button>
<button onClick={() => actions.incrementDelayed(1)}>+ delayed</button>
</div>
);
}
app(initalState, actionsMap, view, document.body);