5 ms·
> I thought react was php for the frontend. Erm. In what way? Ubiquity? Code quality?
by azangru 8y ago
> I thought react was php for the frontend.
Erm. In what way? Ubiquity? Code quality?
- z3t4 8y agoMost people don't know what templates and MVC pattern means. But that's basically what you do in PHP, maybe in a more simple form, but still. Basically how all traditional web apps are built whether its Java perl or cgi. React is pretty much the same, like all other web frameworks, but more powerful as it can rerender parts of the view - instead of the whole view. But if you use it server side I really see no benefit, as you would have to render the whole view. Does this make any sense ?
- azangru 8y agoIf you are then re-using the same React code on the client side (and you generally are), then of course it does. This is the enticement of "universal" frameworks — you use the same code (perhaps with occasional slight modifications here and there) to run on the server side and on the client side. Imagine your Symfony, Django or Rails app that runs not only on your server, but in your browser as well. That’s roughly the luxury that server-side React (or Angular Universal, or Vue, etc.) gives you.
- z3t4 8y agoComponent reuse would be a selling point. But what about stateful components that change colour or what not, do they still run on the client side? And what about a todo-list like the one on the react start page, will it "magically" use hidden forms and make http posts to update the server state ?
- azangru 8y ago> what about stateful components that change colour or what not, do they still run on the client side Yes :-) Statefulness of a component is not useful for server-side rendering anyway, because component state will only change on the client side. But yes, stateful components work both client-side and server-side. > And what about a todo-list like the one on the react start page, will it "magically" use hidden forms and make http posts to update the server state I am not sure what you mean. Filling in and submitting a form only makes sense on the client side. It can be pre-populated with data during server-side rendering though. Naturally, http requests for form submission will work on the client.