@reactivers/hooks Github link@reactivers/hooks NPM link

useLoading

Introduction

  • useLoading helps managing your loading states.
  • You can show a Loading... component easily by component's state or on fetch actions.
const { increase, decrease, isLoading } = useLoading();

Getting Started

  • You need to import useLoading and LoadingProvider.

  • useLoading implements useCounter hook and reads data from LoadingProvider. So you need to wrap your entry component with LoadingProvider.

From Collection

import { useLoading, LoadingProvider } from "@reactivers/hooks";

From Collection

import { useLoading, LoadingProvider } from "@reactivers/use-loading";

Interfaces

Returns

interface IUseLoading {
    
    //Returns True if loading counter bigger than 0
    isLoading: boolean;

    //Increases loading counter
    increase: () => void;
    
    //Decreases loading counter
    decrease: () => void;
}

Example

Example Preview - CodeSandbox