Skip to content

It's a react hook that will help you to control your load states.

License

Notifications You must be signed in to change notification settings

userdansilva/react-hook-load

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Hook Load

It's a react hook that will help you to control your load states

npm downloads npm npm

Installation

npm install react-hook-load

Usage

import React from 'react';
import useLoad from 'react-hook-load';
import { useEffect } from 'react';

function App() {
  const { isLoading, startLoad, stopLoad } = useLoad();

  useEffect(() => {
    setTimeout(() => {
      stopLoad('page');
    }, 3000);
  });

  return (
    <div>
      <p>{isLoading('avatar') ? 'loading...' : 'Show avatar content'}</p>
      <div>
        <button onClick={() => startLoad('avatar')}>Start Load</button>
        <button onClick={() => stopLoad('avatar')}>Stop Load</button>
      </div>

      <section>
        {isLoading('page', true) ? 'loading...' : 'Show page content'}
      </section>
    </div>
  );
}

export default App;

About

It's a react hook that will help you to control your load states.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published