Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
You can’t perform that action at this time.