Instantly share code, notes, and snippets.

What would you like to do?
example creating and updating an object store
# Copying and Updating Store
var a = {name : "chris"}
var postState = {posts: null }
var userState = {name : null }
var store = {postState, userState}
console.log("store: ", store)
// initial state
// Updataed state
// first, userState = {copy previous userState key, update the userState key in store}
userState = {, ...a}
// second, store={copy previous store, updated store}
store = {, userState}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment