From 3939786d027c7e399621541e5bed73e89830f2cc Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Wed, 30 Dec 2020 17:08:19 -0600 Subject: [PATCH] Routing for all --- components/AppShell.jsx | 17 +++++++---------- components/pages/Home.jsx | 2 +- components/pages/ListDetail.jsx | 30 ++++++++++++------------------ components/pages/Lists.jsx | 33 +++++++++++++-------------------- components/pages/Settings.jsx | 2 +- components/ui/Content.jsx | 7 ++----- mock/index.js | 22 ++++++++++++++++++++++ pages/lists/[listId].js | 22 ++++++++++++++++++++++ store/index.js | 23 ++--------------------- 9 files changed, 82 insertions(+), 76 deletions(-) create mode 100644 mock/index.js create mode 100644 pages/lists/[listId].js diff --git a/components/AppShell.jsx b/components/AppShell.jsx index 2c34939..bf71158 100644 --- a/components/AppShell.jsx +++ b/components/AppShell.jsx @@ -22,13 +22,11 @@ import Home from './pages/Home'; import Lists from './pages/Lists'; import Settings from './pages/Settings'; import useLocation from '../hooks/useLocation'; +import ListDetail from './pages/ListDetail'; -const CurrentPage = ({ page }) => { +const CurrentPage = ({ page, pageProps = {} }) => { const currentPage = Store.useState(selectors.getCurrentPage); - const [match, params] = useRoute('/lists'); - console.log('Matches?', match); - // const Page = currentPage.component; const Page = page; const [local, setLocal] = useState(false); @@ -37,18 +35,17 @@ const CurrentPage = ({ page }) => { setLocal(true); }, []); - console.log('Rendering current page', local); - return ( {local ? ( + ) : ( - + )} {/*pages.map(p => { const Page = p.component; @@ -59,7 +56,7 @@ const CurrentPage = ({ page }) => { ); }; -const AppShell = ({ page }) => { +const AppShell = ({ page, pageProps }) => { const [location, setLocation] = useLocation(); const showMenu = Store.useState(selectors.getMenuOpen); @@ -106,7 +103,7 @@ const AppShell = ({ page }) => {