Skip to content

Commit 75e12f1

Browse files
authored
Add control from form context as fallback
1 parent ac8a08e commit 75e12f1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/devTool.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { Control } from 'react-hook-form';
2+
import { useFormContext, Control } from 'react-hook-form';
33
import { Animate } from 'react-simple-animate';
44
import Header from './header';
55
import Panel from './panel';
@@ -8,7 +8,9 @@ import Logo from './logo';
88
import { PanelShadow } from './panelShadow';
99
import { Button } from './styled';
1010

11-
export const DevTool = ({ control }: { control: Control }) => {
11+
export const DevTool = ({ control: controlFromProps }: { control?: Control }) => {
12+
const methods = useFormContext();
13+
const control = controlFromProps || methods.control;
1214
const [visible, setVisible] = React.useState(true);
1315

1416
return (

0 commit comments

Comments
 (0)