@moquality/utility-hooks
v0.0.4
Published
Utility Hooks
Downloads
5
Readme
utility-hooks
Utility Hooks
Install
npm install --save @moquality/utility-hooks
Example
See example on moquality.github.io/utility-hooks
Usage
import {
GlobalStateProvider,
ConfirmProvider,
ToastProvider,
} from '@moquality/utility-hooks'
import { useLocalStorageState, useToast, useGlobalState } from 'utility-hooks'
const App = () => {
const [global, setGlobal] = useGlobalState()
const [data, setData] = useLocalStorageState('example', 'data')
const [showToast, hideToast] = useToast()
return (
<p>Local Storage: {data}</p>
<p>Mode: {global.mode}</p>
<Button
compact
onClick={() => {
showToast('Hi', { id: 1 })
}}
>
Say Hi in a Toast
</Button>
<Button
compact
onClick={() => {
hideToast(1)
}}
>
Hide Toast
</Button>
)
}
ReactDOM.render(
<GlobalStateProvider
initial={{
mode: 'RECORD',
}}
>
<ConfirmProvider>
<ToastProvider>
<App />
</ToastProvider>
</ConfirmProvider>
</GlobalStateProvider>,
document.getElementById('root'),
)
License
Private © moquality
This hook is created using create-react-hook.