Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
useSidebar.tsx - typing-react-context-v1
import { useState, useEffect } from "react";
export type UseSidebar = [
boolean,
React.Dispatch<React.SetStateAction<boolean>>
];
export const useSidebar = (newOpenValue: boolean): UseSidebar => {
const [isOpen, setIsOpen] = useState(true);
useEffect(() => {
setIsOpen(newOpenValue);
}, [newOpenValue]);
return [isOpen, setIsOpen];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment