Skip to content

Commit

Permalink
feat: support React Hook Form V7 #56
Browse files Browse the repository at this point in the history
BREAKING CHANGE: require react-hook-form v7
  • Loading branch information
jorisre committed Apr 9, 2021
2 parents f778333 + 47e43a8 commit cce1b56
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@
"prettier": "^2.2.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-hook-form": "^6.11.4",
"react-hook-form": "^7.0.5",
"rimraf": "^3.0.2",
"ts-jest": "^26.5.4",
"typescript": "^4.2.4"
},
"peerDependencies": {
"react": ">=16.8.0",
"react-dom": ">=16.8.0",
"react-hook-form": ">=6.6.0"
"react-hook-form": "^7.0.0"
},
"husky": {
"hooks": {
Expand Down
2 changes: 1 addition & 1 deletion src/ErrorMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const ErrorMessage = <
...rest
}: Props<TFieldErrors, TAs>) => {
const methods = useFormContext();
const error = get(errors || methods.errors, name);
const error = get(errors || methods.formState.errors, name);

if (!error) {
return null;
Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react';
import {
Assign,
FieldName,
Message,
MultipleFieldErrors,
FieldErrors,
} from 'react-hook-form';

type Assign<T extends object, U extends object> = T & Omit<U, keyof T>;

export type FieldValuesFromFieldErrors<
TFieldErrors
> = TFieldErrors extends FieldErrors<infer TFieldValues> ? TFieldValues : never;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5784,10 +5784,10 @@ react-dom@^17.0.2:
object-assign "^4.1.1"
scheduler "^0.20.2"

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

react-is@^16.8.1:
version "16.13.1"
Expand Down

0 comments on commit cce1b56

Please sign in to comment.