Skip to content

Commit cce1b56

Browse files
authored
feat: support React Hook Form V7 #56
BREAKING CHANGE: require react-hook-form v7
2 parents f778333 + 47e43a8 commit cce1b56

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@
8181
"prettier": "^2.2.1",
8282
"react": "^17.0.2",
8383
"react-dom": "^17.0.2",
84-
"react-hook-form": "^6.11.4",
84+
"react-hook-form": "^7.0.5",
8585
"rimraf": "^3.0.2",
8686
"ts-jest": "^26.5.4",
8787
"typescript": "^4.2.4"
8888
},
8989
"peerDependencies": {
9090
"react": ">=16.8.0",
9191
"react-dom": ">=16.8.0",
92-
"react-hook-form": ">=6.6.0"
92+
"react-hook-form": "^7.0.0"
9393
},
9494
"husky": {
9595
"hooks": {

src/ErrorMessage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const ErrorMessage = <
1818
...rest
1919
}: Props<TFieldErrors, TAs>) => {
2020
const methods = useFormContext();
21-
const error = get(errors || methods.errors, name);
21+
const error = get(errors || methods.formState.errors, name);
2222

2323
if (!error) {
2424
return null;

src/types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import React from 'react';
22
import {
3-
Assign,
43
FieldName,
54
Message,
65
MultipleFieldErrors,
76
FieldErrors,
87
} from 'react-hook-form';
98

9+
type Assign<T extends object, U extends object> = T & Omit<U, keyof T>;
10+
1011
export type FieldValuesFromFieldErrors<
1112
TFieldErrors
1213
> = TFieldErrors extends FieldErrors<infer TFieldValues> ? TFieldValues : never;

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -5784,10 +5784,10 @@ react-dom@^17.0.2:
57845784
object-assign "^4.1.1"
57855785
scheduler "^0.20.2"
57865786

5787-
react-hook-form@^6.11.4:
5788-
version "6.15.5"
5789-
resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-6.15.5.tgz#c2578f9ce6a6df7b33015587d40cd880dc13e2db"
5790-
integrity sha512-so2jEPYKdVk1olMo+HQ9D9n1hVzaPPFO4wsjgSeZ964R7q7CHsYRbVF0PGBi83FcycA5482WHflasdwLIUVENg==
5787+
react-hook-form@^7.0.5:
5788+
version "7.0.5"
5789+
resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.0.5.tgz#33d4a437be78ca1fe86867ed937fe94b09c4bf9c"
5790+
integrity sha512-NERg22pjSa8URYfNhDhefGVODMTP4DMLlkK+bpuN4GUWKYIh/qiV4YmPuH8bfMAcXKj+bpdh6n7dB5B6jBs74Q==
57915791

57925792
react-is@^16.8.1:
57935793
version "16.13.1"

0 commit comments

Comments
 (0)