const [open, handleOpen, handleClose] = useOpen()
Last active
July 16, 2021 19:56
-
-
Save izszzz/d9e7a0946e1bbb9ce05d96866549d4fc to your computer and use it in GitHub Desktop.
React useOpen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react"; | |
const useOpen = (): [boolean, () => void, () => void] => { | |
const [open, setOpen] = useState(false); | |
const handleOpen = () => setOpen(true); | |
const handleClose = () => setOpen(false); | |
return [open, handleOpen, handleClose]; | |
}; | |
export default useOpen; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment