File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -37,12 +37,12 @@ export const FormContext: FC<FormContextProps> = props => {
3737
3838 const isFirstRender = React . useRef ( true )
3939
40- const watchedInputs = methods . watch ( )
40+ if ( typeof onChange === 'function' ) {
41+ const watchedInputs = methods . watch ( )
4142
42- if ( isFirstRender . current === true ) {
43- isFirstRender . current = false
44- } else if ( typeof onChange === 'function' ) {
45- onChange ( getObjectFromForm ( props . schema , watchedInputs ) )
43+ if ( isFirstRender . current === false ) {
44+ onChange ( getObjectFromForm ( props . schema , watchedInputs ) )
45+ }
4646 }
4747
4848 const idMap = useMemo ( ( ) => getIdSchemaPairs ( props . schema ) , [ props . schema ] )
@@ -78,6 +78,10 @@ export const FormContext: FC<FormContextProps> = props => {
7878 formProps . noValidate = props . noNativeValidate
7979 }
8080
81+ if ( isFirstRender . current === true ) {
82+ isFirstRender . current = false
83+ }
84+
8185 return (
8286 < InternalFormContext . Provider value = { formContext } >
8387 < form { ...formProps } > { props . children } </ form >
You can’t perform that action at this time.
0 commit comments