Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
import { create as createJsondiffpatch } from 'jsondiffpatch'
import clone from 'clone'
const jsondiffpatch = createJsondiffpatch({})
function reducer(state = {}, action) {
switch (action.type) {
const initialState = action.payload
return initialState
case 'PATCH':
const diff = action.diff
return jsondiffpatch.patch(clone(state), diff)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment