New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

material-ui-global-loading

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

material-ui-global-loading

hook of global loading base on material ui

latest
Source
npmnpm
Version
0.1.3
Version published
Maintainers
1
Created
Source

material-ui-global-loading

Confirming user choice is a good thing to do, it should also be easy to do.

This package provides simple global loading built on top of @mui/material and straightforward to use thanks to React Hooks.

Installation

npm install --save material-ui-global-loading

Usage

Wrap your app inside the GlobalLoadingProvider component.
Note: If you're using Material UI ThemeProvider, make sure GlobalLoadingProvider is a child of it.

import React from "react";
import { GlobalLoadingProvider } from "material-ui-global-loading";

const App = () => {
  return <GlobalLoadingProvider>{/* ... */}</GlobalLoadingProvider>;
};

export default App;

Call the useGlobalLoading hook wherever you need the openLoading,closeLoading function.
Note: A component calling useGlobalLoading must be a child of GlobalLoadingProvider.

import React from "react";
import Button from "@mui/material/Button";
import { useGlobalLoading } from "material-ui-global-loading";

const Item = () => {
  const { openLoading, closeLoading } = useGlobalLoading();

  const handleClick = async() => {
    openLoading();

    try {
        {/* ... */}
    } catch(error) {
        {/* ... */}
    }

    closeLoading();
  };

  return <Button onClick={handleClick}>Click</Button>;
};

export default Item;

Keywords

loading

FAQs

Package last updated on 13 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts