What's the difference between hydrate() and render() in React 16?

后端 未结 6 899
我寻月下人不归
我寻月下人不归 2021-01-30 05:53

I\'ve read the documentation, but I didn\'t really understand the difference between hydrate() and render() in React 16.

I know hydrate()

6条回答
  •  甜味超标
    2021-01-30 06:51

    In addition to above...

    ReactDOM.hydrate() is same as render(), but it is used to hydrate(attach event listeners) a container whose HTML contents were rendered by ReactDOMServer. React will attempt to attach event listeners to the existing markup.

    Using ReactDOM.render() to hydrate a server-rendered container is deprecated because of slowness and will be removed in React 17 so use hydrate() instead.

提交回复
热议问题