Skip to content

Instantly share code, notes, and snippets.

@thinkgarden
Created November 13, 2018 02:50
Show Gist options
  • Save thinkgarden/1d67256ecdc037939b050227f903ca22 to your computer and use it in GitHub Desktop.
Save thinkgarden/1d67256ecdc037939b050227f903ca22 to your computer and use it in GitHub Desktop.
[js object]
const getIn = (state, path) => {
if (!state) {
return state
}
const length = path.length
if (!length) {
return undefined
}
let result = state
for (let i = 0; i < length && !!result; ++i) {
result = result[path[i]]
}
return result
}
const merge = (state,paylod) => ({...state, ...payload})
getIn(state, ['router', 'location'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment