r/javascript • • Aug 27 '15

Stop Using React for EVERYTHING!

https://medium.com/@zackargyle/stop-using-react-for-everything-c8297ac1a644
3 Upvotes

131 comments sorted by

View all comments

7

u/te7ris Aug 27 '15

give me one good reason NOT to use react for everything.

-1

u/geuis Aug 27 '15
  • search engine reachable content

  • content intended to be embedded in other sites

  • non-js browsers

That's 3.

14

u/daedius Web Components fanboy Aug 27 '15
  • Isomorphic react libraries?

  • iframes?

  • React native?

5

u/KhalilRavanna Aug 27 '15

Also per the first one you can also render react on the server and serve the rendered HTML. No libraries (outside of react) required.

3

u/Poop_is_Food Aug 27 '15

that's what isomorphic means. (yeah it's a pretentious word)

2

u/KhalilRavanna Aug 27 '15

Righto-- isomorphic running the same code on both front/back end-- I just meant to point out that there are no 3rd party libraries required and that react does this out of the box.

1

u/xxxabc123 Aug 28 '15

No libraries (outside of react) required.

Assuming server also works on javascript. If you're running let's say Java or Ruby, you're going to need even weirder hacks to execute in a javascript environment such as Rhino. Even if node.js makes it relatively easy, this would be quite hard for big teams where front-end and back-end developers might never meet during their employment, as I'm currently experiencing.

1

u/theQuandary Aug 28 '15

The React render to string methods make a string from the vdom and return it. That should work perfectly well in Rhino or any other ECMAScript compliant implementation.

For large projects that need to be isomorphic, a great solution is to spin rendering off into a separate node process. Your java, python, ruby, or whatever passes in the required data and gets back a string that can be returned to the client and (in a lot of cases) cached for reuse.

Your front-end team is going to have to write this template code anyway. The benefit here is that it allows more graceful upgrades on the client and allows the client to reuse as much of the back-end as possible (which reduces template overhead and potential conflicts).

If large companies like Netflix or Facebook (with PHP no less) can make these ideas work, then I don't doubt that other companies can as well.

2

u/rq60 Aug 27 '15

I used iframes the first time I needed to embed a "widget" in another site; it worked out terribly thanks to mobile safari's awesome bugs. I'll stick to javascript DOM insertion and hopefully web components in the future, thanks.

1

u/[deleted] Aug 28 '15

I like how you conveniently leave out making a snide remark about sever side rendering of react components.