Something is being rendered multiple times
Unanswered
Colima Warbler posted this in #help-forum
Colima WarblerOP
I can't tell what is happening, but for some reason I'm getting tags being rendered multiple times.
layout.tsx code
'use client';
import Game from './square-pop-game';
export const metadata = {
title: "Square Pop",
description: "PLACEHOLDER",
};
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<>
hello from layout!
<Game />
</>
);
}layout.tsx code
9 Replies
@Colima Warbler I can't tell what is happening, but for some reason I'm getting tags being rendered multiple times.
'use client';
import Game from './square-pop-game';
export const metadata = {
title: "Square Pop",
description: "PLACEHOLDER",
};
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<>
hello from layout!
<Game />
</>
);
}
layout.tsx code
is this RootLayout at app/layout.tsx? if so, you need to put html and body tag there like below
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}@Ray is this RootLayout at app/layout.tsx? if so, you need to put html and body tag there like below
ts
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}
Colima WarblerOP
When I do that I have the same thing, rendered from the page entry
'use client';
import Game from "./square-pop-game";
function SquarePop() {
return (
<>
<Game />
Hello from page!
</>
)
}
export default SquarePop;English Angora
I think it's the background. The gradient seems to be tiled.
Colima WarblerOP
based on the global it is the
body tag that is getting re-rendered@tailwind base;
@tailwind components;
@tailwind utilities;
:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}
@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}
}
body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}English Angora
You can check to see for sure if the body is being rendered multiple times by putting text in the body component.
I suspect its the background. I originally had a repeating gradient in my site and it looked like that. I had to style the html component also. https://github.com/M-Valentino/M-Valentino_Node/blob/main/src/pages/_document.js