Closed MonsterDeveloper closed 1 month ago
@AlemTuzlak I've been trying to write tests but didn't manage... I'm not very experienced with unit testing React hooks, maybe you can come up with a solution. For now it seems like the useMemo
is not triggered when the mocked value of useNavigation
, so the useEffect
is never triggered...
False alarm, managed to get it working. Added a test case that fails when using current version of the hook and passes on the new one.
@AlemTuzlak do you mind taking a look, please?
Hvala:)
Mind doing some minor changes?
Done!
Fixes #101
Description
I described the issue in #101. This PR is my attempt to fix the bug.
I added a separate state variable to keep track of whether we're actually submitting the form through the network. It is activated when
onSubmit
is called, and is de-activated when thefetcher
ornavigation
state (through theisSubmittingForm
variable) are idle.Then in the hook return we set
isSubmitting
asisSubmittingNetwork || methods.formState.isSubmitting
, which means "actually submitting the form through the network or the internal react-hook-form hook is doing it's part."Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Checklist:
I have made corresponding changes to the documentationN/AAny dependent changes have been merged and published in downstream modulesN/A