first commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { useState } from "react";
|
||||
|
||||
function useToggle(init = false) {
|
||||
const [value, setValue] = useState(init);
|
||||
return [
|
||||
value,
|
||||
{
|
||||
set: setValue,
|
||||
toggle: (e) => {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
setValue((flag) => !flag);
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
export default useToggle;
|
||||
Reference in New Issue
Block a user