DEV Community

Discussion on: No, disabling a button is not app logic.

Collapse
 
mrvaa5eiym profile image
mrVAa5eiym

Hi all what about this? am I missing something?

  async function handleSubmit(event: FormEvent<HTMLFormElement>) {
    event.preventDefault();

    if (state.status === 'loading') {
      return;
    }

    dispatch({ type: ActionType.sentData });

    try {
      await axios.request({
        // some code
      });

      dispatch({ type: ActionType.success });
    } catch (error) {
      dispatch({ type: ActionType.error });
    }
  }
Enter fullscreen mode Exit fullscreen mode