ORESoftware · GitHub

Alright, kind of a React newb but React is not following the principle of least surprises with this one so I have to ask.

Our team only really wants serverside rendering for a particular project. We don't need to do much special on the client.

However, as far as I have learned, you need to have a reference to the same React components on the client as you do on the server in order to actually get dynamic behavior (events are bound etc) on the client.

My question is, if we have a <div id='react-root'> </div>

why isn't React setup so that on the front-end we could just call:

ReactDOM.render(document.getElementById('react-root');

(without the React component first argument.)

Doesn't / couldn't React have enough info to go off of already, so as to not need an actual reference to the React component on the front-end as well? As long as React on the front-end has a reference to the root DOM node, couldn't / shouldn't that be enough?

The whole thing where you have to re-render on the client is kinda unexpected. I am sure I am missing something, or there must be some good reason why the lib works this way, I just don't know and want to know which is why I am writing this. Thanks.

Read the original on github.com ↗