Skip to content

Does relay-nextjs support NextJS per-page layout? #97

Closed Answered by sahidrahman404
sahidrahman404 asked this question in Q&A
Discussion options

You must be logged in to vote

Oops, sorry for the confusion. To get the layout working correctly, I realized that I need to assign the getLayout() method to the return value of the withRelay() function.

const RelayFilmList = withRelay(FilmList, FilmListQuery, {
  createClientEnvironment: () => getClientEnvironment()!,
  createServerEnvironment: async () => {
    const { createServerEnvironment } = await import(
      'lib/server/relay_server_environment'
    );

    return createServerEnvironment();
  },
});


RelayFilmList.getLayout = (page: ReactNode) => {
  return (
    <Layout>
      {page}
    </Layout>
  )
}

export default RelayFilmList

Replies: 1 comment 3 replies

Comment options

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

@sahidrahman404
Comment options

@sahidrahman404
Comment options

Answer selected by sahidrahman404
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants