facebook / react

The library for web and native user interfaces.
https://react.dev
MIT License
227.68k stars 46.45k forks source link

About the performance for mounting ReactComponents #4075

Closed huxiaoqi567 closed 9 years ago

huxiaoqi567 commented 9 years ago

Hi, I'm trying to implement ListView Components run on browser. Then I found that React. renderToString , React.renderToString is not performance as well as I need.

View the react source code, I found the function mountComponent cost performance. Do you have a better way for this?

code here:

function renderToString(element) { return transaction.perform(function() { var componentInstance = instantiateReactComponent(element, null); //low performance here !!! ------------------------------ var markup = componentInstance.mountComponent(id, transaction, emptyObject); //low performance here !!! ------------------------------

}

sophiebits commented 9 years ago

Virtually all of the component code runs in that .mountComponent call, so it's not surprising that you found it took most of the runtime. We're been continually trying to make performance improvements to React and will continue to do so.