Skip to content

Instantly share code, notes, and snippets.

@frivolta

frivolta/index.tsx

Last active Sep 4, 2020
Embed
What would you like to do?
index.tsx - typing-react-context-v1
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