UNPKG

@e-group/material-form

Version:

Custom react components for integrate redux-form.

12 lines (10 loc) 444 B
/** * To solve index path bug please read this for more detail. * https://stackoverflow.com/questions/6393943/convert-javascript-string-in-dot-notation-into-an-object-reference */ const indexPath = (obj = {}, path = '') => { var _path$match; const matchArray = (_path$match = path.match(/[^\]\\[.]+/g)) !== null && _path$match !== void 0 ? _path$match : []; return matchArray.reduce((o, i) => o[i], obj); }; export default indexPath;