use-flash-state
v1.0.0
Published
A React hook to set state on a timer. Great for showing flash messages!
Downloads
1
Readme
use-flash-state
A React hook to set state on a timer. Great for showing flash messages!
Install
npm install --save use-flash-state
Usage
import React from 'react'
import {useFlashState} from 'use-flash-state'
import {Banner, Button, Form} from '@benderthecrime/components'
const Example = () => {
const [{showSuccessMessage}, setFlashState] = useFlashState({showSuccessMessage: false})
return <Form
onSubmit={(e) => {
e.preventDefault()
// ...
setFlashState({showSuccessMessage: true})
}}
>
<Banner open={showSuccessMessage}>Success</Banner>
<Button type="submit">
</Form>
}
License
MIT © @benderTheCrime
This hook is created using create-react-hook.