Skip to content

Commit

Permalink
upgrade react to v17
Browse files Browse the repository at this point in the history
  • Loading branch information
teeeteee committed Aug 28, 2022
1 parent 50ecce2 commit 4b8ea12
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 91 deletions.
27 changes: 15 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"src"
],
"engines": {
"node": ">=10"
"node": ">=16"
},
"scripts": {
"start": "tsdx watch",
Expand All @@ -18,7 +18,7 @@
"prepare": "tsdx build"
},
"peerDependencies": {
"react": ">=16"
"react": ">=17"
},
"husky": {
"hooks": {
Expand All @@ -36,24 +36,27 @@
"author": "Ginger",
"module": "dist/react-use-form.esm.js",
"devDependencies": {
"@testing-library/react-hooks": "^5.0.2",
"@types/jest": "^26.0.4",
"@testing-library/react-hooks": "^7.0.2",
"@types/jest": "^27.5.2",
"@types/lodash.debounce": "^4.0.6",
"@types/lodash.get": "^4.4.6",
"@types/lodash.set": "^4.3.6",
"@types/lodash.debounce": "^4.0.6",
"@types/react": "^16.9.41",
"@types/react-dom": "^16.9.8",
"@types/react": "^17.0.48",
"@types/react-dom": "^17.0.17",
"husky": "^4.3.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"tsdx": "^0.14.0",
"tslib": "^2.0.1",
"typescript": "^4.0.3"
"tsdx": "^0.14.1",
"tslib": "^2.4.0",
"typescript": "^4.8.2"
},
"resolutions": {
"@types/react": "^17.0.48"
},
"dependencies": {
"immer": "^9.0.6",
"lodash.debounce": "^4.0.8",
"lodash.get": "^4.4.2",
"lodash.set": "^4.3.2",
"lodash.debounce": "^4.0.8"
"lodash.set": "^4.3.2"
}
}
2 changes: 1 addition & 1 deletion src/useForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function useForm<T extends Record<string, any>>(
}
}

function getInitialState<T>(
function getInitialState<T extends Record<string, any>>(
fieldDefs: FieldDefinitions<T>,
defaultValue?: T
): FieldsState<T> {
Expand Down
5 changes: 4 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export function forEach<T>(
}
}

export function validate<T>(data: T, fieldDefs: FieldDefinitions<T>): boolean {
export function validate<T extends Record<string, any>>(
data: T,
fieldDefs: FieldDefinitions<T>
): boolean {
let isValid = true
forEach<FieldDefinition<any>>(fieldDefs, (path, { rules }) => {
const value = get(data, path)
Expand Down
2 changes: 1 addition & 1 deletion test/useForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ async function validate<T>(currentForm: UseForm<T>): Promise<boolean> {
return Promise.resolve(isValid)
}

function render<T>(
function render<T extends Record<string, any>>(
fieldDefs: FieldDefinitions<T>,
defaultValue?: T
): RenderHookResult<unknown, UseForm<T>> {
Expand Down
Loading

0 comments on commit 4b8ea12

Please sign in to comment.