diff --git a/src/useFormState.js b/src/useFormState.js index 3602d62..83be72f 100644 --- a/src/useFormState.js +++ b/src/useFormState.js @@ -22,13 +22,19 @@ function useFormState({ form.subscribe((state) => { initialState = state; }, subscription)(); - if (onChange) { - onChange(initialState); - } return initialState; }, ); + React.useEffect( + () => { + if (onChange) { + onChange(state); + } + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [], + ); React.useEffect( () => form.subscribe((newState) => {