Last active
September 4, 2020 07:46
-
-
Save frivolta/9b162985396ab2b29e477287ab0092d7 to your computer and use it in GitHub Desktop.
index.tsx - typing-react-context-v1
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 * as React from "react"; | |
import { render } from "react-dom"; | |
import { SidebarProvider, useSidebarContext } from "./useSidebarContext"; | |
import { ChildComponent } from "./childComponent"; | |
export const App = () => { | |
const [isOpen] = useSidebarContext(); | |
return ( | |
<div> | |
<p>Main component context: {isOpen ? "Open" : "Closed"}</p> | |
<ChildComponent /> | |
</div> | |
); | |
}; | |
const rootElement = document.getElementById("root"); | |
render( | |
<SidebarProvider> | |
<App /> | |
</SidebarProvider>, | |
rootElement | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment