Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

There is a way to remove component <Header /> inside _app.tsx in one single page?

I have a component inside my _app.tsx file, This componennt is rendered in all pages, but I want that in my page payment.tsx this component doesnt exist, there is some way to do it?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Something like this should work:

// pages/payment

export default function Payment() {
  // ...
}

Payment.hideHeader = true;
// pages/_app

import Header from '...';

export default function App({ Component, pageProps }) {
  return (
    <>
      {!Component.hideHeader && <Header />}
      <Component {...pageProps} />
    </>
  );
}

You might need to customize types, etc. as you’re using TS. Refer this: https://nextjs.org/docs/basic-features/layouts#with-typescript.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading