Skip to content

Instantly share code, notes, and snippets.

View Stringsaeed's full-sized avatar
building something that matters

Muhammad Saeed Stringsaeed

building something that matters
View GitHub Profile
import { useCallback, useState } from 'react';
// Usage
function App() {
// Call the hook which returns, current value and the toggler function
const [isTextChanged, setIsTextChanged] = useToggle();
return (
<button onClick={setIsTextChanged}>{isTextChanged ? 'Toggled' : 'Click to Toggle'}</button>