Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade react to v17 #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.5.3",
"version": "0.6.0",
"license": "Apache-2.0",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand All @@ -18,7 +18,7 @@
"prepare": "tsdx build"
},
"peerDependencies": {
"react": ">=16"
"react": ">=17"
},
"husky": {
"hooks": {
Expand All @@ -36,24 +36,24 @@
"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"
},
"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