Created
July 31, 2021 17:09
-
-
Save noizbuster/29d44ec6b61319465e138a10a619ab05 to your computer and use it in GitHub Desktop.
utilities for hookstate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _ from 'lodash'; | |
export function cloneState(stateValue, path) { | |
const value = path ? _.get(stateValue, path) : stateValue; | |
if (!value) { | |
return value; | |
} | |
return JSON.parse(JSON.stringify(value)); | |
} | |
export function partialUpdate(key, value) { | |
return (p) => ({ ...p, [key]: value }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment