Created
February 22, 2021 20:18
-
-
Save dev-cyprium/95fab3a0f3ee9ae63b29c6f25d2b7347 to your computer and use it in GitHub Desktop.
Recap
This file contains hidden or 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 { createContext, useContext, useState, useEffect } from "react"; | |
| const RouterContext = createContext(/* Context */); | |
| const Home = () => { | |
| /* The route view */ | |
| } | |
| const Page = () => { | |
| /* The page view */ | |
| } | |
| const AppRouter = ({ children }) => { | |
| /* Storing the state and providing it to the rest of the application */ | |
| }; | |
| const RouterView = ({ config }) => { | |
| /* Dynamically rendering the component that's 'selected' */ | |
| }; | |
| export default function App() { | |
| return ( | |
| <AppRouter> | |
| {/* ... rest of the markup */} | |
| <main className="flex-1 px-4 py-2"> | |
| <RouterView config={{ "/": Home, "/page": Page }} /> | |
| </main> | |
| </AppRouter> | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment