I'm working on a new i18n library for Next.js.
Sometimes there is information that can only be known on the client-side, e.g. a number n which determines whether to render a singular or plural.
In my library, for a plural you would write something like:
<Plural n={n} singular={<>I have <Num value={n}/> book.</>}> I have <Num value={n}/> books.</Plural>Because the pluralization and number formatting logic changes depending on the value of n, if is being used on the client-side, there needs to be a useEffect() somewhere or there will be a hydration mismatch. Unfortunately, adding a useEffect() causes flickering/blinking since there has to be a render cycle before the correct plural can be displayed.
Using next/dynamic also causes a flickering effect. Using suppressHydrationWarning only works one level deep, so fails in situations where you want to render alternate branches (like plurals).
Is there a way around this flickering?