Lucifier129 / react-lite

An implementation of React v15.x that optimizes for small script size
MIT License
1.73k stars 100 forks source link

Server side generated HTML is completely rerendered #92

Closed rsadyhov closed 7 years ago

rsadyhov commented 7 years ago

I found out that there is no benefit of server side rendering with React as React Lite completely removes main node from browser DOM and substitutes it with what is rendered on UI during first page load.

This can be seen during debug of react-lite.common.js on line #1923. Per my understanding this logic is executed all the time after page load and there is no way to omit it.

It's causing troubles for our project as we do have other mechanisms in parallel to React, which are changing the browser DOM. As result our changes our wiped out and we need to rely on React Lite lifecycle, which is causing performance degradation.

It would be great to have similar mechanism which exists in React and compares checks sums of server side generated content and content of UI side rendered virtual DOM. So if they are equal, it will just perform component mounting, but not full rerender.

Lucifier129 commented 7 years ago

Sorry about that. It' hard to make react-lite reuse the html rendered by server-side, because react-lite do not support renderToString|renderToStaticMarkup for keeping script size smaller.

This inconsistent behaviour has been mentioned in README, visit different with React

rsadyhov commented 7 years ago

Thank you for the quick response!