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, useCallback } from "react"; | |
function useToggle(initialValue = false){ | |
// State with initial boolean value (true/false) | |
const [state, setState] = useState(initialValue); | |
// Let's create a toggle function | |
// This works, but we're using the state value from above | |
// instead of the current state. Usually they are the same, | |
// but if this hook was triggered multiple times rapidly then |