在服务器上,出于 SEO 的原因,我们总是希望显示详细的 H1。然而,在移动客户端上,由于屏幕空间有限,我们希望显示较短的 H1。
这导致:Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
例如,想象一个关于第二次世界大战的页面,它是关于希特勒的。想要的结果是:
客户:<h1> History </h1>
....(在手机等小型设备上)
服务器:<h1> History, World War 2, Hitler </h1>
..(和桌面设备)
有人对如何解决这个问题有任何想法吗?是否应该忽略此警告?还是有更好的方法来实现这一目标?