(initialState)
| 5 | ) => readonly [boolean, (forced?: boolean) => void]; |
| 6 | |
| 7 | export const useToggle: UseToggle = (initialState) => { |
| 8 | const [state, setState] = useState(initialState); |
| 9 | const toggle = (forced?: boolean) => { |
| 10 | if (typeof forced === 'boolean') { |
| 11 | setState(forced); |
| 12 | return; |
| 13 | } |
| 14 | |
| 15 | setState((value) => !value); |
| 16 | }; |
| 17 | return [state, toggle] as const; |
| 18 | }; |
no outgoing calls
no test coverage detected