Skip to content

Commit 9f0ca2b

Browse files
authored
fix #51 wiith RHF 6.5.0 (#52)
* fix #51 wiith RHF 6.5.0 * fix devtool
1 parent 14ac1a7 commit 9f0ca2b

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hookform/devtools",
3-
"version": "2.1.0",
3+
"version": "2.1.1-beta.2",
44
"description": "React Hook Form dev tool to help debugging forms",
55
"main": "dist/index.js",
66
"umd:main": "dist/index.umd.development.js",
@@ -84,7 +84,7 @@
8484
"prettier": "^2.0.5",
8585
"react": "^16.13.1",
8686
"react-dom": "^16.13.1",
87-
"react-hook-form": "^6.0.0",
87+
"react-hook-form": "^6.5.0",
8888
"rimraf": "^3.0.2",
8989
"rollup": "^2.10.7",
9090
"rollup-plugin-peer-deps-external": "^2.2.2",
@@ -97,7 +97,7 @@
9797
"peerDependencies": {
9898
"react": ">=16.8.0",
9999
"react-dom": ">=16.8.0",
100-
"react-hook-form": ">=6.0.0"
100+
"react-hook-form": ">=6.5.0"
101101
},
102102
"husky": {
103103
"hooks": {

src/devTool.test.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ describe('DevTool', () => {
2727
},
2828
},
2929
fieldsValues: {},
30-
errorsRef: {
31-
current: {},
32-
},
33-
formState: {
34-
dirtyFields: {},
30+
formStateRef: {
31+
current: { dirtyFields: {} },
3532
},
3633
readFormStateRef: { current: {} },
3734
} as any

src/header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const Header = ({ setVisible, control }: Props) => {
3030
transition: '0.5s all',
3131
color:
3232
control.readFormStateRef.current.isValid &&
33-
control.formState.isValid
33+
control.formStateRef.current.isValid
3434
? colors.green
3535
: colors.lightPink,
3636
}}

src/panel.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Button, Input } from './styled';
1010
import { setCollapse } from './settingAction';
1111

1212
export default ({
13-
control: { fieldsRef, getValues, formState, errorsRef, readFormStateRef },
13+
control: { fieldsRef, getValues, readFormStateRef, formStateRef },
1414
}: {
1515
control: Control;
1616
}) => {
@@ -107,13 +107,14 @@ export default ({
107107
name,
108108
)
109109
.map(([name, value], index) => {
110-
const error = get(errorsRef.current, name);
110+
const error = get(formStateRef.current.errors, name);
111111
const errorMessage = get(error, 'message', undefined);
112112
const errorType = get(error, 'type', undefined);
113113
const type = get(value, 'ref.type', undefined);
114-
const isTouched = !!get(formState.touched, name);
114+
const isTouched = !!get(formStateRef.current.touched, name);
115115
const isNative = (value as any).ref.type;
116-
const isDirty = !!Object.keys(formState.dirtyFields).length;
116+
const isDirty = !!Object.keys(formStateRef.current.dirtyFields)
117+
.length;
117118
const hasError = !!error;
118119
const ref = get(value, 'ref');
119120

@@ -147,7 +148,7 @@ export default ({
147148

148149
<FormStateTable
149150
readFormStateRef={readFormStateRef}
150-
formState={formState}
151+
formState={formStateRef.current}
151152
showFormState={showFormState}
152153
setShowFormState={setShowFormState}
153154
/>

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4774,10 +4774,10 @@ react-dom@^16.13.1:
47744774
prop-types "^15.6.2"
47754775
scheduler "^0.19.1"
47764776

4777-
react-hook-form@^6.0.0:
4778-
version "6.0.0"
4779-
resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-6.0.0.tgz#b51faa638aadfa3d4d9758dc1f8d0f67c2b1aa97"
4780-
integrity sha512-qFUMMnAMnZ84mcMFu/UZ6zkuEUQg/dAKdb9/wbjmOJ/KOgrobTx15aMGPhZyemzk6yLHwG7NmJCEOusRTV9UMg==
4777+
react-hook-form@^6.5.0:
4778+
version "6.5.1"
4779+
resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-6.5.1.tgz#504389d09970f2e7fc8c5ec8db2c551c863bcde9"
4780+
integrity sha512-MakeW3CRj4n1FW4HuliM8vlWup+5keUWDduf5lPlori6OWQ616xGzxrUOKoDUIGh0ERgCebObrLb5UiFDlSxAQ==
47814781

47824782
react-is@^16.12.0, react-is@^16.8.1, react-is@^16.8.4:
47834783
version "16.12.0"

0 commit comments

Comments
 (0)