Skip to content

Commit

Permalink
optimize lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
le0pard committed Oct 26, 2024
1 parent 2a86aa7 commit f43237d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"formik": "^2.4.6",
"highlight.js": "^11.10.0",
"jest": "^29.7.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"normalize.css": "^8.0.1",
"postcss": "^8.4.47",
"postcss-import": "^16.1.0",
Expand Down
5 changes: 5 additions & 0 deletions src/common/components/configurationForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect, useMemo } from 'react'
import { useDispatch } from 'react-redux'
import { useSearchParams } from 'react-router-dom'
import classnames from 'classnames'
import { isEmpty } from 'lodash-es'
import { Formik, Field, Form } from 'formik'
import FormField from '@common/components/form/field'
import FormDropdown from '@common/components/form/dropdown'
Expand Down Expand Up @@ -123,6 +124,10 @@ const ConfigurationForm = () => {
}, [searchParams])

const formParams = useMemo(() => {
if (isEmpty(urlParams)) {
return FORM_DEFAULTS
}

let vParams = urlParams

try {
Expand Down
4 changes: 2 additions & 2 deletions src/common/components/form/dropdown.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import PropTypes from 'prop-types'
import _camelCase from 'lodash/camelCase'
import { camelCase } from 'lodash-es'
import Tooltip from './tooltip'

import './dropdown.css'

const FormDropdown = ({ label, tooltip, options, field, form: { touched, errors }, ...rest }) => {
const dropdownID = _camelCase(`${field.name}-id`)
const dropdownID = camelCase(`${field.name}-id`)
const isError = touched[field.name] && errors[field.name]

return (
Expand Down
4 changes: 2 additions & 2 deletions src/common/components/form/field.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import PropTypes from 'prop-types'
import _camelCase from 'lodash/camelCase'
import { camelCase } from 'lodash-es'
import Tooltip from './tooltip'

import './field.css'

const FormField = ({ label, tooltip, field, form: { touched, errors }, ...rest }) => {
const inputID = _camelCase(`${field.name}-id`)
const inputID = camelCase(`${field.name}-id`)
const isError = touched[field.name] && errors[field.name]

return (
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7600,7 +7600,7 @@ __metadata:
formik: "npm:^2.4.6"
highlight.js: "npm:^11.10.0"
jest: "npm:^29.7.0"
lodash: "npm:^4.17.21"
lodash-es: "npm:^4.17.21"
normalize.css: "npm:^8.0.1"
postcss: "npm:^8.4.47"
postcss-import: "npm:^16.1.0"
Expand Down

0 comments on commit f43237d

Please sign in to comment.