Image Flickering on page change
Answered
Arinji posted this in #help-forum
ArinjiOP
const montserrat = Montserrat({ subsets: ["latin"] });
export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
};
export default async function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
const parsedOptions = await unstable_cache(
async () => {
const data = await fetch(
`${process.env.NEXT_PUBLIC_PAYLOAD_URL}/api/article`,
{
headers: {
Authorization: `users API-Key ${process.env.API_KEY}`,
},
}
);
const options = await data.json();
const parsedOptions: SearchSchemaType[] = options.docs.map(
(option: any) => {
const parse = SearchSchema.safeParse(option);
if (parse.success) return parse.data as SearchSchemaType;
}
);
return parsedOptions;
},
["key"],
{ tags: ["searchTAG"], revalidate: false }
)();
return (
<html lang="en">
<body className={`${montserrat.className} bg-shades-dark`}>
<div className="w-full bg-shades-dark h-[180px] relative flex flex-col items-center justify-center">
<Image
fill
src="/banner.png"
alt="Banner"
sizes="100vw"
className="w-full h-full absolute object-cover object-[90%_90%] "
/>
<div className="...."></div>
<div className="...">
<Image
src="/logo.webp"
alt="Logo"
width={100}
height={100}
className=" absolute top-0 left-0 object-contain"
/>
<SearchBar options={parsedOptions} />
<div className="w-full h-full flex flex-col items-center justify-center">
{children}
</div>
</body>
</html>
);
}
Thats my layout.tsx with the image being the banner image... im so confused why the image is resizing.... its on prod mode btw
11 Replies
ArinjiOP
Bump
@Arinji Bump
import it statically
Answer
@DirtyCajunRice | AppDir import it statically
ArinjiOP
Like import from ...
Why though?
Why though?
Usually it works normally
@Arinji Like import from ...
Why though?
because what you are doing it bad and is client rendering all the images 😂
@Arinji Usually it works normally
it works has nothing to do with if its good practice
@DirtyCajunRice | AppDir because what you are doing it bad and is client rendering all the images 😂
ArinjiOP
Oh shit it does? My bad lmao all of my projects do that xD
Lemm try and let you know if it works
ArinjiOP
@DirtyCajunRice | AppDir uh so i found the problem
the importing thing, helped with the resizing.. but it keps flickering
wanna know why?... i used an a tag xD