Skip to content

Commit

Permalink
refactor: replace lodash.isequal with fast-equals
Browse files Browse the repository at this point in the history
  • Loading branch information
jrson83 committed May 11, 2024
1 parent 72c03fc commit 6717177
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 47 deletions.
3 changes: 1 addition & 2 deletions packages/preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
},
"dependencies": {
"@inertiajs-revamped/core": "workspace:*",
"@types/lodash.isequal": "^4.5.8",
"lodash.isequal": "^4.5.0",
"fast-equals": "^5.0.1",
"preact": "^10.21.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/preact/src/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type VisitOptions,
router,
} from '@inertiajs-revamped/core'
import isEqual from 'lodash.isequal'
import { deepEqual } from 'fast-equals'
import { useCallback, useEffect, useRef, useState } from 'preact/hooks'
import { useRemember } from './useRemember'

Expand Down Expand Up @@ -211,7 +211,7 @@ export function useForm<TForm extends FormDataType>(
setData(keyOrData as TForm)
}
},
isDirty: !isEqual(data, defaults),
isDirty: !deepEqual(data, defaults),
errors,
hasErrors,
processing,
Expand Down
3 changes: 1 addition & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@
},
"dependencies": {
"@inertiajs-revamped/core": "workspace:*",
"@types/lodash.isequal": "^4.5.8",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0",
"lodash.isequal": "^4.5.0",
"fast-equals": "^5.0.1",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type VisitOptions,
router,
} from '@inertiajs-revamped/core'
import isEqual from 'lodash.isequal'
import { deepEqual } from 'fast-equals'
import { useCallback, useEffect, useRef, useState } from 'react'
import { useRemember } from './useRemember'

Expand Down Expand Up @@ -211,7 +211,7 @@ export function useForm<TForm extends FormDataType>(
setData(keyOrData as TForm)
}
},
isDirty: !isEqual(data, defaults),
isDirty: !deepEqual(data, defaults),
errors,
hasErrors,
processing,
Expand Down
3 changes: 1 addition & 2 deletions packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
},
"dependencies": {
"@inertiajs-revamped/core": "workspace:*",
"@types/lodash.isequal": "^4.5.8",
"lodash.isequal": "^4.5.0",
"fast-equals": "^5.0.1",
"vue": "^3.4.27"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
getStructuredClone,
router,
} from '@inertiajs-revamped/core'
import isEqual from 'lodash.isequal'
import { deepEqual } from 'fast-equals'
import { reactive, watch } from 'vue'

export type FormDataType = object
Expand Down Expand Up @@ -286,7 +286,7 @@ export function useForm<TForm extends FormDataType>(
watch(
form,
(newValue) => {
form.isDirty = !isEqual(form.data(), defaults)
form.isDirty = !deepEqual(form.data(), defaults)
if (rememberKey) {
router.remember(getStructuredClone(newValue.__remember()), rememberKey)
}
Expand Down
50 changes: 15 additions & 35 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6717177

Please sign in to comment.