birdofpreyru/react-utils

Re-think the usage of lazy() for code-splitting

Closed this issue · 0 comments

const LazyComponent = lazy(async () => {
const res = await getComponent();
if (heap.pendingStyles.length) await Promise.all(heap.pendingStyles);
return res.default ? res : { default: res };
});

^ This is bad, according to React docs: https://react.dev/reference/react/lazy#my-lazy-components-state-gets-reset-unexpectedly

Probably this is what caused #285