How to make a server rendering with part of the code run only on a client?

南笙酒味 提交于 2019-12-25 04:09:13

问题


I have window dependency in some of modules I use, so I cannot render part of my app on a server. However the content send from a server should be the same as a content rendered on a client first time, otherwise there will be a: "React attempted to use reuse markup in a container but the checksum was invalid" warning.

Seems like I need to do some workaround, render the content from a server and then, after component is mounted, render a client only part. Similar issue described here.

I feel this is the best solution, however eslint from AirBnB throws an error that changing state in componentDiMount is not good.

Do you have better ideas?

来源:https://stackoverflow.com/questions/39007875/how-to-make-a-server-rendering-with-part-of-the-code-run-only-on-a-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!