Skip to content

Commit fe129b5

Browse files
TketaAlmouro
authored andcommitted
refactor: Replace custom function with lodash get
1 parent 7fd4096 commit fe129b5

4 files changed

Lines changed: 9 additions & 19 deletions

File tree

src/makeReactNativeField.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { compose, mapProps } from "recompose";
2+
import _ from 'lodash';
3+
24
import withFormik from "./withFormik";
3-
import { selectValue } from './utils';
45

56
const makeReactNativeField = compose(
67
withFormik,
78
mapProps(({ formik: { setFieldValue, setFieldTouched, values }, name, ...props }) => ({
8-
value: selectValue(values, name),
9+
value: _.get(values, name),
910
...props,
1011
name,
1112
onChangeText: text => {

src/utils.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/withError.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { compose, mapProps } from "recompose";
2+
import _ from 'lodash';
3+
24
import withFormik from "./withFormik";
3-
import { selectValue } from './utils';
45

56
const withError = compose(
67
withFormik,
78
mapProps(({ formik: { errors }, name, ...props }) => ({
8-
error: selectValue(errors, name),
9+
error: _.get(errors, name),
910
...props,
1011
name
1112
}))

src/withTouched.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { compose, mapProps } from "recompose";
2+
import _ from 'lodash';
3+
24
import withFormik from "./withFormik";
3-
import { selectValue } from './utils';
45

56
const withError = compose(
67
withFormik,
78
mapProps(({ formik: { touched }, name, ...props }) => ({
8-
touched: selectValue(touched, name),
9+
touched: _.get(touched, name),
910
...props,
1011
name
1112
}))

0 commit comments

Comments
 (0)