ar-design
Version:
AR Design is a (react | nextjs) ui library.
14 lines (13 loc) • 624 B
JavaScript
"use client";
import React, { createContext, useState } from "react";
import ReactDOM from "react-dom";
import Loading from "../../../../components/feedback/loading";
const LoadingContext = createContext({ isLoading: false, setIsLoading: () => { } });
const LoadingProvider = ({ children }) => {
// states
const [isLoading, setIsLoading] = useState(false);
return (React.createElement(LoadingContext.Provider, { value: { isLoading, setIsLoading } },
children,
isLoading && ReactDOM.createPortal(React.createElement(Loading, null), document.body)));
};
export { LoadingContext, LoadingProvider };