I have a sign up form that accepts basic username/password data. This needs to authenticate against a graphql endpoint using a custom hook. React Hooks rules dictate, you cannot call a hook within an event handler. How else can the custom hook be invoke to perform the authentication once the user submits the form?
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (2)
Obviously, as the docs state, you are not allowed to execute hooks inside of an event handler and other forbidden things.
As a workaround, you can execute fetch... Ultimately, what I am looking for is interaction with the graphql endpoint. So a simple fetch does the job.
Do you have a code snippet or a repo you can show as without code it's pretty hard to help you
I could guess that you're using some sort of library(apollo) for graphql if this is the case something like the following should work
this is in no way working code but the usage should be clear