Hero: keep the plain HTML region after hydration, add the slider around it
Replacing the region at hydration made new nodes (a late LCP candidate). The first photo, the title and the buttons now stay; the other slides, arrows and controls are added on top. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,7 @@ const TIMEOUT_MS = 8000;
|
||||
export default function useHero(
|
||||
baked: HeroData,
|
||||
load: LoadJson = loadFromApi,
|
||||
): HeroData {
|
||||
): { hero: HeroData; regionHero: HeroData } {
|
||||
const hydrated = useHydrated();
|
||||
const fromBlock = useMemo(() => {
|
||||
const block = hydrated ? hostCmsData(document) : null;
|
||||
@@ -45,5 +45,12 @@ export default function useHero(
|
||||
};
|
||||
}, [load]);
|
||||
|
||||
return fromBlock ?? fetched ?? baked;
|
||||
// regionHero is what the plain HTML region of the page holds: the baked
|
||||
// hero, or the one the API gave. The block of the host does not count: the
|
||||
// host wrote that region itself and it must not be written over (that
|
||||
// would replace the photo the browser has painted).
|
||||
return {
|
||||
hero: fromBlock ?? fetched ?? baked,
|
||||
regionHero: fetched ?? baked,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user