- Issue created by @balintbrews
- ๐ฌ๐งUnited Kingdom AaronMcHale Edinburgh, Scotland
balintbrews โ credited aaronmchale โ .
- ๐ญ๐บHungary Gรกbor Hojtsy Hungary
balintbrews โ credited gรกbor hojtsy โ .
- ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
balintbrews โ credited wim leers โ .
- ๐ณ๐ฑNetherlands balintbrews Amsterdam, NL
Crediting people who were part of the discussion that led to the ADR at Drupal Dev Days in Leuven.
- Merge request !913#3519737: Plan how to evolve code component overrides โ (Open) created by Unnamed author
- ๐บ๐ธUnited States effulgentsia
I really like the option 2 proposal that's in the ADR. My one nit though is I don't think we should do it as a custom hook, but instead as a plain async function that's passed to React 19's use() API. In other words, instead of:
import { useMenuData } from '@/lib/menu'; const NavigationMenu = ({ menuId, level }) => { const menuData = useMenuData(menuId, { level }); // ... }
to do:
import { use } from 'react'; import { fetchMenuData } from '@/lib/menu'; const NavigationMenu = ({ menuId, level }) => { const menuData = use(fetchMenuData(menuId, { level })); // ... }
This would then also work for other UI frameworks when we add support for them in the future, which we might do soon as part of the CLI work. For example, in Svelte:
{#await fetchMenuData(menuId, { level }) then menuData} ... {/await}
One hiccup with this approach though is that
preact/compat
doesn't implement theuse()
function. I opened https://github.com/preactjs/preact/issues/4756, but we can't count on that getting done in time. However, I think we can work around that by implementing our ownuse()
function until such time as Preact implements the proper one, and ours can sidestep the need to work withSuspense
, because we can rely on either server-side prefetching or async Astro island hydration to make sure we don't hydrate the component until we've already fetched the data and can return it synchronously by the timeuse()
is called.