Skip to content

Commit

Permalink
refactor: Replace custom function with lodash get
Browse files Browse the repository at this point in the history
  • Loading branch information
Tketa authored and Almouro committed Jul 10, 2018
1 parent 7fd4096 commit fe129b5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
5 changes: 3 additions & 2 deletions src/makeReactNativeField.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { compose, mapProps } from "recompose";
import _ from 'lodash';

import withFormik from "./withFormik";
import { selectValue } from './utils';

const makeReactNativeField = compose(
withFormik,
mapProps(({ formik: { setFieldValue, setFieldTouched, values }, name, ...props }) => ({
value: selectValue(values, name),
value: _.get(values, name),
...props,
name,
onChangeText: text => {
Expand Down
13 changes: 0 additions & 13 deletions src/utils.js

This file was deleted.

5 changes: 3 additions & 2 deletions src/withError.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { compose, mapProps } from "recompose";
import _ from 'lodash';

import withFormik from "./withFormik";
import { selectValue } from './utils';

const withError = compose(
withFormik,
mapProps(({ formik: { errors }, name, ...props }) => ({
error: selectValue(errors, name),
error: _.get(errors, name),
...props,
name
}))
Expand Down
5 changes: 3 additions & 2 deletions src/withTouched.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { compose, mapProps } from "recompose";
import _ from 'lodash';

import withFormik from "./withFormik";
import { selectValue } from './utils';

const withError = compose(
withFormik,
mapProps(({ formik: { touched }, name, ...props }) => ({
touched: selectValue(touched, name),
touched: _.get(touched, name),
...props,
name
}))
Expand Down

0 comments on commit fe129b5

Please sign in to comment.