Skip to content

UI/UX: Lack of Loading States during Authentication #6

@codeCraft-Ritik

Description

@codeCraft-Ritik

Description:

When a user clicks "Login" or "Register," there is no visual feedback indicating that the request is in progress. Users might think the site is frozen and click the button multiple times, which can trigger duplicate network requests or cause the application to behave unexpectedly.

Solution:
Utilize the loading state provided by the Apollo useMutation hook to disable the submit button and show a spinner or "Loading..." text while the request is pending.

Code Implementation: In client/src/pages/Auth/Login.js and Register.js:

const [loginUser, { loading, error }] = useMutation(LOGIN_USER);

// In the return statement:
<button type="submit" disabled={loading}>
  {loading ? "Logging in..." : "Login"}
</button>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions