onClick handler not registering with ReactDOMServer.renderToString

前端 未结 2 869
南笙
南笙 2021-02-07 21:50

I am trying to copy this fiddle: http://jsfiddle.net/jhudson8/135oo6f8/

(I also tried this example http://codepen.io/adamaoc/pen/wBGGQv and the same onClick

2条回答
  •  梦谈多话
    2021-02-07 22:40

    None of the hooks will register with ReactDOMServer.RenderToString. If you want to accomplish server side rendering + hooks on your react component, you could bundle it on the client (webpack, gulp, whatever), and then also use ReactDOMServer.RenderToString on the server.

    Here's a blog post that helped me accomplish this: https://www.terlici.com/2015/03/18/fast-react-loading-server-rendering.html

提交回复
热议问题