Skip to content

Implementing /app/[slug]/dashboard, /app/[slug]/settings in an app #11187

Answered by vvo
vvo asked this question in Help
Discussion options

You must be logged in to vote

Ok now solved I believe, here's how to do it properly (? please confirm :D):

pages/_app.js:

import React from "react";
import dynamic from "next/dynamic";

const layouts = {
  AppLayout: dynamic(() => import("../components/layouts/AppLayout")),
  Main: function Main({ children }) {
    return <div>{children}</div>;
  },
};

function MyApp({ Component, pageProps }) {
  const Layout = layouts[Component.layout || "Main"];

  return (
    <Layout>
      <Component {...pageProps} />
    </Layout>
  );
}

export default MyApp;

components/layouts/AppLayout.js:

export default function AppLayout({children}) {
  return <>{children}</>
}

pages/app/[organization]/dashboard.js:

function Dashboard() {
  

Replies: 3 comments 8 replies

Comment options

vvo
Mar 18, 2020
Collaborator Author

You must be logged in to vote
1 reply
@vvo
Comment options

vvo Mar 18, 2020
Collaborator Author

Comment options

vvo
Mar 18, 2020
Collaborator Author

You must be logged in to vote
3 replies
@vvo
Comment options

vvo Mar 18, 2020
Collaborator Author

@timneutkens
Comment options

@vvo
Comment options

vvo Mar 19, 2020
Collaborator Author

Answer selected by vvo
Comment options

You must be logged in to vote
4 replies
@timneutkens
Comment options

@TommySorensen
Comment options

@timneutkens
Comment options

@TommySorensen
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants