Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Home.jsx #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Commits on Oct 7, 2023

  1. Update Home.jsx

    Error Handling:
    
    We added a new state variable error using useState to handle errors that may occur during the API request for fetching questions.
    Inside the handleSubmit function, we wrapped the API request in a try-catch block to catch any potential errors.
    If an error occurs during the API request, we set the error state with an error message to inform the user.
    We added a conditional rendering block to display the error message in red if error is not null.
    Feedback for Loading:
    
    We provided feedback to the user during the loading process by using the HashLoader component from 'react-spinners' to display a loading spinner.
    The loading spinner is displayed in the center of the screen while questions are being fetched.
    The loading state is controlled by the loading state variable from the context.
    Improved Styling and Layout:
    
    We made minor styling improvements, such as centering text and the loading spinner on the screen.
    We used Chakra UI's Text component to style and display the error message in red if there is an error.
    User-Friendly Error Message:
    
    In the error message, we provide a user-friendly error message, such as "Failed to fetch questions. Please try again," to inform the user about the issue.
    These changes enhance the user experience by providing better feedback during loading and handling errors gracefully when fetching questions from the API.
    rishi457 authored Oct 7, 2023
    Configuration menu
    Copy the full SHA
    34cc2e6 View commit details
    Browse the repository at this point in the history