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.

0

u/[deleted] Aug 27 '15

[deleted]

→ More replies (2)

4

u/te7ris Aug 27 '15

they are all invalid. You can achieve all 3 w/ react.

1

u/MisterSticks Aug 27 '15

In development, there is no such thing as an absolute.

0

u/geuis Aug 27 '15

No, they aren't. React is complete overkill for lots of the uses people have been using it for.

Going back the last 5 years, we've had Backbone, Ember, Knockout, Cappucino, Marionette, Angular 1, Angular 2, React, Virtual Dom, and even more frameworks I'm not recalling right now. It has been a constant progression of one js framework to the next, all trying to solve the same problems in a variety of ways.

Meanwhile, actual work has been done just building sites based on the best practices of the last 20 years with tons of practical advancements being made with low level protocols and new browser capabilities.

Yes, I have used most of these frameworks. For a vary narrow set of application types, they are suitable. But they are not useful for the majority.

4

u/te7ris Aug 27 '15

define overkill. If you think size in kb, think again.

-2

u/MisterSticks Aug 27 '15

Just curious, where are you employed that is using React in production?

7

u/nathanjd Aug 27 '15

At Nordstrom we are rebuilding the entire site with React (yes, even on the servers). Only ~0.5% of users are seeing it in production at the moment, but more is coming soon! So far it has been faster than any previous overhaul attempt and is looking to be very maintainable. It really is a pleasure to work with.

1

u/MisterSticks Aug 28 '15

Fantastic, what was it built with before?

1

u/nathanjd Aug 28 '15

Mostly jQuery and mustache composed as AMD modules pulled in with require.js. The backend was varying flavors of MVC .NET. It got the job done and required little on-boarding time but was very difficult to maintain.

React + flux in comparison provides a very prescriptive way to modularize code that promotes re-use across the company. We've begun publishing our common components to a private NPM registry to get some SemVer goodness.

The only pain point so far has been jest, but it's easy enough to use a different unit testing framework. I'm very partial to mocha with chai assertions.

1

u/MisterSticks Aug 28 '15

Do you think most of the maintainability was gained by refactoring:

The backend was varying flavors of MVC .NET.

If not, what was the biggest benefit of the switch? Could you be more detailed about how React is being used on the backend vs. what you had before?

→ More replies (0)

5

u/misc_ent Aug 27 '15

Facebook uses it production. They don't open source any project unless its in production.

http://opensource.com/business/15/7/keynote-oscon-james-pearce-facebook?sc_cid=70160000000wptgAAA&elq=1a1afca5d20b45348ea180631ab778f1&elqCampaignId=55450&elqaid=20324&elqat=1&elqTrackId=77990e8d9e1f4f7ca81f707e22b2ce9e

The projects they're open sourcing are not just hackfest ideas or work that interns contribute, these are tools Facebook uses in production. Facebook open sources only what it uses in production—this way, people know that their offerings are supported and valuable.

→ More replies (3)

3

u/te7ris Aug 27 '15

the projects I work on for my employer (3 days a week) dont use react (they have their own stack). The rest of my time I spend on developing a pretty big react project which is not yet in production. Had 2 small React projects (SPAs for interal stuff) before that.

1

u/MisterSticks Aug 28 '15

React hasn't been in the wild for more than a year, do you have any personal projects that predate React?

2

u/te7ris Aug 28 '15

I first picked up react dec 14' and had tried various things with it. The most frustrating was trying to combine libs that havily change the DOM with the react-render-cycle. Why are you asking?

→ More replies (3)
→ More replies (1)
→ More replies (1)