react-hook-loading
v0.0.9
Published
React hook of useLoading
Downloads
6
Readme
react-hook-loading
Made with create-react-library
Install
npm install --save react-hook-loading
Usage
App.js
import React from 'react'
import {LoadingProvider} from 'react-hook-loading'
import YourLoading from './YourLoading'
import Hello from './Hello'
export default function App(){
return (
<LoadingProvider loading={<YourLoading />}>
<Hello/>
</LoadingProvider>
)
}
Hello.js
import React, {useEffect} from 'react'
import {useLoading} from 'react-hook-loading'
export default () => {
const [loading, setLoading] = useLoading()
useEffect(() => {
setLoading(true) // show modal loading
setTimeout(() => {
setLoading(false) // hide modal loading
}, 2000)
}, [])
return <div>hello world</div>
}
License
MIT © min9nim