repo.or.cz
/
ProtonMail-WebClient.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git]
/
packages
/
components
/
hooks
/
useToggle.ts
blob
622707b3c80b7c69cf65c927723fbef65b02f4a8
1
import { useEffect, useState } from 'react';
2
3
const useToggle = (initialState = false) => {
4
const [state, setState] = useState(initialState);
5
const toggle = () => setState(!state);
6
7
useEffect(() => {
8
setState(initialState);
9
}, [initialState]);
10
11
return {
12
state,
13
toggle,
14
set: setState,
15
};
16
};
17
18
export default useToggle;