Skip to content

Instantly share code, notes, and snippets.

View nathanforce's full-sized avatar

Nathan Force nathanforce

  • Headway
  • New York, New York
View GitHub Profile

Emotion + Streaming SSR + Suspense

Note: This document describes a workaround for a known limitation in Emotion's handling of React 18+ streaming SSR with Suspense. This should be considered a temporary fix until Emotion or the React ecosystem provides first-class support.

The Problem

Hydration mismatch errors occur when using Emotion (or Emotion-based libraries like Material-UI, Chakra UI) with React 18+ streaming SSR and Suspense boundaries.

Root Cause

type AAndB = {
a: string;
b: string;
};
type Neither = {
someOtherProp: string;
};
type Props = AAndB | Neither;