18 ms·
Nitpick, but React is not a framework, it's a library. People miss this point often eg when they compare React to Angular
by bauerd 6y ago
Nitpick, but React is not a framework, it's a library. People miss this point often eg when they compare React to Angular
- was744 6y agoWikipedia says it's both https://en.wikipedia.org/wiki/React_(web_framework) https://en.wikipedia.org/wiki/React_(web_framework)
- jerrycruncher 6y agoYeah, I think that prior to the public release of the Context api (16.3) and Hooks (16.6), one could more easily make the argument that "it's just a display library." Providing convenient mechanisms for managing high-level/application state moves them squarely into the framework category, imo.
- deleted 6y ago[deleted]
- simonbarker87 6y agoI think this is an important nitpick though in your defence. I have just started learning React having become pretty competent with Angular (day job plus some hybrid apps) and I have to say that I'm struggling to understand its popularity compared to Angular. Angular feels fully fleshed out, adheres to MVC mostly and has nice separation of html, css and the UI TS code. I come from a native coding background so this feels logical and I can jump into a new project and get my bearings pretty quickly. React on the other hand seems to be jQuery gone mad with CSS, JS and pseudo HTML all mixed together. Ternary statements in JSX is awful to look at. To me it seems React is solely there to solve the V in MVC and then with a host of additional libraries (of the users choice) some kind of MVC system can be cobbled together if needs be. I'm not saying React is bad, clearly it is very popular and has it's great use cases, but I don't think it's Angular vs React.
- nicoburns 6y agoTo me, the killer feature of React is how easy it is to mix with standard "vanilla" JS libraries. The "React" version of a library is usually a fairly trivial wrapper around the "normal" version. In contrast, integrating with Angular is a lot more involved and is in effect its own ecosystem. The other thing I can't stand about Angular is that it puts its proprietary templating language "in control" of components. Which means if you want to do something more complicated that isn't implemented in the templating language, then you just can't (or you end up fighting the framework). With React, it's as if the equivalent of Angular's controllers (components? - it's been a while since I used Angular) were in control. The templating is only for templating. FWIW, I agree on the ternary operator issue. Although IMO this is actually a deficiency in JavaScript rather than in React/JSX: If if-else and switch in JavaScript were expressions then this problem would disappear completely.
- jiofih 6y agoCan you provide some examples? My experience is that almost any library you end up using is built specifically for React and not vanilla.
- enumjorge 6y agoRedux can be used in projects unrelated to React.
- rejschaap 6y agoI have used react-sortablejs and react-leaflet in the past. I don't have any experience actually wrapping existing libraries myself though. https://github.com/SortableJS/react-sortablejs https://github.com/SortableJS/react-sortablejs https://react-leaflet.js.org/ https://react-leaflet.js.org/
- nicoburns 6y agoCompare https://github.com/nhagen/react-intercom/blob/master/src/index.js https://github.com/nhagen/react-intercom/blob/master/src/ind... with https://github.com/PatrickJS/angular-intercom/blob/master/angular-intercom.js https://github.com/PatrickJS/angular-intercom/blob/master/an... And that's the small one. There's also https://github.com/CaliStyle/ng-intercom https://github.com/CaliStyle/ng-intercom As another example, consider HTTP. Angular provides its own special HTTP class. With React I just use the standard Fetch API.
- cryptica 6y ago>> but React is not a framework It's a framework which advertises itself as a library. In reality, there is nothing library-like about bypassing the DOM for rendering and making developers use a custom programming language (JSX)... and please don't give me this tired old argument that JSX is not compulsory! Has anyone ever seen a real React application which does not use JSX? Exactly. If 99.9999% of developers are using React as a framework, then for all general communication purposes, React is a framework.
- qudat 6y ago> Has anyone ever seen a real React application which does not use JSX? I've built one without using JSX and I think it's superior. The problem is the tooling and type support just isn't there so going against the grain here is pretty much asking to be burnt.
- tashoecraft 6y agoI think React is both and when you describe it as either will depend on how you're using it. If you have a website with a couple of React components here and there, then you have React the library. If you have your app setup as a SPA, with react router, redux, react forms, maybe you started the app with createReactApp, etc, then you are using React the framework. I don't see how you can argue it's not a framework when every single piece of your app is a react specific piece. It's no longer just a view layer, it's an ecosystem of modules whose common ground is to turn React into a framework.
- bauerd 6y ago>If you have you're app setup as a SPA, with react router, redux, react forms, maybe you started the app with createReactApp, etc, then you are using React the framework react-router, redux etc. are all different libraries. Point still stands: You have to pick and assemble these different parts yourself. And then still all those libraries don't call into your code, but your code includes and wires them up.
- tashoecraft 6y agoWhether or not they are different libraries doesn't matter. Once you've done any real development with them good luck trying to take out your small, simple library and replace it with another. Why are so many React devs so against the word framework, it's like they treat it how many treat monolith "It's a bad word we can't be compared against, even when you can't tell us apart"
- fendy3002 6y agoWell I sometimes use react to replace a component, such as develop a button which needs to be clicked twice to submit just by simple state management. Though I don't know if it still can be considered as framework or not.
- tashoecraft 6y agoThen it's a library, which I stated in my first comment "If you have a website with a couple of React components here and there, then you have React the library.". I'm mostly just trying to point out was seems to be an aversion to the word framework by the react community, when in most cases it is. It's not bad to be a framework, it has loads of benefits, but it's not a bad word that needs to be reviled at all times.
- vishnu_ks 6y agoWhat is difference between a front-end library and a front-end framework?
- jfkebwjsbx 6y agoA library is added to a project. A project is added to a framework.
- dntrkv 6y agoI agree with this definition. So how is React a library? You can't just utilize part of React within an existing Angular app. I've built shims between the two frameworks and you can't just use React inside of Angular. When you utilize a React component inside of Angular, everything Angular about the application goes out the window and it becomes a mini React app starting from that component, just with the data originating from an Angular app. The definition of a framework boils down to inversion of control, right? You define your application, and then it is run within the React "framework" context, which calls various predefined methods/functions. All of the lifecycle methods in React are a good indicator, to me, that it is indeed a framework. You define these functions, and they are called by the framework. Inversion of control.
- stblack 6y agoYour code calls a library. A framework calls your code. Really great explanation here: https://stackoverflow.com/posts/15600924/revisions https://stackoverflow.com/posts/15600924/revisions Edit: another really nice exposé here: The Difference Between a Framework and a Library — https://www.freecodecamp.org/news/the-difference-between-a-framework-and-a-library-bd133054023f/ https://www.freecodecamp.org/news/the-difference-between-a-f...
- luhego 6y agoMoment.js is a library, you can use in any part of your app and it doesn't define how your application is going to work. You are in charge of the flow of the application. React pretty much defines how your application is going to work from the beginning. It can call itself a "library" but by any practical means, it isn't.
- fendy3002 6y agoKinda disagree. Though I usually use it as a full page form, it's easy to use it as single component and use it via javascript natively. Let's say that if I want my own version of select2, I can develop it with react, though not easy.
- jgwil2 6y agoReact's documentation calls it a library but we don't have to. I think the reason people go back and forth on this is that there are a couple definitions of framework out there. A lot of people consider it to be a sort of continuum, where a library becomes framework-like as it adds more and more functionality. I understand that framework can sometimes connote bloat, which is probably why the React docs avoid the term. And I think it's perfectly reasonable to say that frameworks are a subset of libraries, so perhaps they're not strictly wrong to describe React as a library. But, as others have pointed out in this thread, a much more useful distinction is where the library's code gets called in the stack. If your code is at the top of the call stack with library code below it, then it's a framework. If their code is at the top, then it's a library. In short, you call a library, a framework calls you (inversion of control). So in that sense React is most definitely a framework. Also, I'm willing to be wrong on this one if somebody can give me a meaningful and objective reason that React should be considered a library but Angular should be considered a framework.
- acemarke 6y agoReact _is_ a framework, because: - You hand it your code and it calls your code when it wants to - Your code must conform to React's expectations. React is _not_ a framework, because: - It only focuses on one thing: defining a tree of UI components. It doesn't include anything for HTTP requests, module definitions, generating expected file structures, or any of the other stuff you'd see in Angular and Ember. - You are responsible for initializing React in your app, and you can use it in a range of situations, from a full-bore SPA to adding some interactive widgets to an existing page. All those are true simultaneously.
- jgwil2 6y agoThey are true simultaneously only if we allow two definitions of "framework" to exist simultaneously. As someone who prefers precise language, I think there should only be one such definition, namely the inversion of control definition.