Skip to content

Instantly share code, notes, and snippets.

View andriichern's full-sized avatar

Andrii Chernenko andriichern

View GitHub Profile
@andriichern
andriichern / store.js
Created May 15, 2020 12:43 — forked from kitze/store.js
simplified redux
import produce from 'immer';
import {createStore} from 'redux';
const handleActions = (actionsMap, defaultState) => (
state = defaultState,
{type, payload}
) =>
produce(state, draft => {
const action = actionsMap[type];
action && action(draft, payload);