useSidebarContext.tsx - typing-react-context-v1-v2
import React from "react"; | |
import { useSidebarContext } from "./useSidebarContext"; | |
export const ChildComponent: React.FC = () => { | |
const [isOpen, setIsOpen] = useSidebarContext(); | |
return ( | |
<> | |
<p>Sidebar is: {isOpen ? "Open" : "Closed"}</p> | |
<button onClick={() => setIsOpen(!isOpen)}>Toggle sidebar</button> | |
</> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment