Package Exports
- react-global-loader
- react-global-loader/dist/index.es.js
- react-global-loader/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-global-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
React Global Loader
Simple Customizable Global React Loader.
Install
npm i react-global-loaderSimple Usage
Import LoaderContainer in App.js or root js
import { LoaderContainer } from "react-global-loader";
export default function App() {
return (
<div>
<LoaderContainer />
</div>
);
}Usage inside pages, components and services
import { loader } from "react-global-loader";
export default function PageName() {
const showLoader = () => {
loader.show();
};
const hideLoader = () => {
loader.hide();
};
useEffect(() => {
showLoader();
setTimeout(() => {
hideLoader();
}, 3000);
});
return <div>Page 1</div>;
}Extended Usage
import { LoaderContainer, loader } from "react-global-loader";
export default function App() {
const showLoader = () => {
loader.show();
};
const hideLoader = () => {
loader.hide();
};
useEffect(() => {
showLoader();
setTimeout(() => {
hideLoader();
}, 3000);
});
const Arrow = () => (
<div
style={{
width: 0,
height: 0,
borderTop: "10px solid transparent",
borderRight: "20px solid red",
borderBottom: "10px solid transparent",
}}
></div>
);
return (
<div>
<LoaderContainer opacity={0.5} backgroundColor="#ccc">
<div style={{ display: "inline-flex" }}>
<Arrow />
<div style={{ marginLeft: "10px" }}> Custom Loader</div>
</div>
</LoaderContainer>
</div>
);
}Using with react-loader-spinner Usage
If you are familiar with react-loader spinner please do check out the official page and npm page .
import { Audio } from "react-loader-spinner";
import { LoaderContainer, loader } from "react-global-loader";
export default function App() {
useEffect(() => {
loader.show();
setTimeout(() => {
loader.hide();
}, 5000);
});
return (
<LoaderContainer>
<Audio
height="100"
width="100"
color="#4fa94d"
ariaLabel="audio-loading"
wrapperStyle={{}}
wrapperClass="wrapper-class"
visible={true}
/>
</LoaderContainer>
);
}Container Properties
| Property | Default Value | Type |
|---|---|---|
| opacity | 1 | number |
| backgroundColor | #0000003a | string |
| justify | center | string |
| justify | center | string |
| defaultText | Loading.. | string |