score:1

function MyApp({ Component, pageProps, router }) {
  const adminPanel = router.route.startsWith('/admin-panel') ? true : false
  const getLayout =
    adminPanel ? ((page) => <AdminLayout children={page} />)
      : ((page) => <FrontLayout children={page} />);

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

score:2

const App = ({ Component, pageProps, router }) => {
    const getLayout =
        router.pathname.includes('/admin') ? ((page) => <AdminLayout children={page} />)
        : ((page) => <FrontLayout children={page} />);

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

Related Query

More Query from same tag