Skip to content

Commit 155b4eb

Browse files
committed
Wrap hydrated components in IslandProvider to set context
1 parent b81799e commit 155b4eb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

dotcom-rendering/src/client/islands/doHydration.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { isUndefined, log, startPerformanceMeasure } from '@guardian/libs';
55
import { createElement } from 'react';
66
import { hydrateRoot } from 'react-dom/client';
77
import { ConfigProvider } from '../../components/ConfigContext';
8+
import { IslandProvider } from '../../components/IslandContext';
89
import type { Config } from '../../types/configContext';
910

1011
declare global {
@@ -61,7 +62,11 @@ export const doHydration = async (
6162
element,
6263
<ConfigProvider value={config}>
6364
<CacheProvider value={emotionCache}>
64-
{createElement(module[name], data)}
65+
{/* Child islands should not be hydrated separately */}
66+
<IslandProvider value={{ child: true }}>
67+
{/* The component to hydrate must be a single JSX Element */}
68+
{createElement(module[name], data)}
69+
</IslandProvider>
6570
</CacheProvider>
6671
</ConfigProvider>,
6772
);

0 commit comments

Comments
 (0)