question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Per-page layouts are not rendering

See original GitHub issue

I’m using per-page layouts as described here https://nextjs.org/docs/basic-features/layouts#per-page-layouts and when I use them with next-translate the layout is not rendering. Can I get some help? Thank you very much

nextJS version: 11.1.2 and 12.0.1 (tried both) next-translate version: 1.1.1

// Layout.tsx

export const Layout = ({ children }: PropsWithChildren<unknown>): JSX.Element => {
  return (
    <main>
      {children}
    </main>
  );
};
// index.tsx

import { Layout } from '@components';

const Home = (): JSX.Element => {
  const { t } = useTranslation();

  return (
    <div>
        {t('home:description')}
    </div>
  );
};

Home.getLayout = (page: PageProps) => <Layout>{page}</Layout>;

export default Home;
// _app.tsx

function MyApp({ Component, pageProps }: Props): JSX.Element {
  const getLayout = Component.getLayout || ((page) => page);

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

export default MyApp;

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
rmlevangeliocommented, Jul 1, 2022

Thanks @aralroca for this solution!

1reaction
aralrocacommented, Nov 2, 2021

no problem, we all make mistakes ! I’m glad it’s working for you then. I close the issue

do you recommend me that? Should I avoid this?

It’s good that you do it this way, it doesn’t take up that much hoist-non-react-statics (1.2kb) and it’s used by most libraries that use HOC to copy everything.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Per-page layouts are not rendering · Issue #717 - GitHub
I'm using per-page layouts as described here https://nextjs.org/docs/basic-features/layouts#per-page-layouts and when I use them with ...
Read more >
NextJS Layout component not rendering page content [closed]
This "should" render my different page content and Menu/Footer should be visible on every page I create. I can see the Menu/Footer on...
Read more >
Fields Are Not Visible on a New Page Layout for Certain Users
Fields Are Not Visible on a New Page Layout for Certain Users · Select the name of the user · Click Profile ·...
Read more >
Basic Features: Layouts - Next.js
Learn how to share components and state between Next.js pages with Layouts.
Read more >
Embedded VF Page Not Rendering on Page Layout
I am having an issue with the dynamic pick list field displaying on the Account page when I add it to the page...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found