src/structure/plain/getIn.js
// @flow
import { toPath } from 'lodash'
const getIn = (state: Object | Array<any>, field: string): any => {
if (!state) {
return state
}
const path: string[] = toPath(field)
const length = path.length
if (!length) {
return undefined
}
let result: any = state
for (let i = 0; i < length && result; ++i) {
result = result[path[i]]
}
return result
}
export default getIn