6 ms·
> "you call a library, but a framework calls you." This is why I don't like when people say "React isn't a framework, it's just a library". Almost all of my Re
by Uehreka 5y ago
> "you call a library, but a framework calls you."
This is why I don't like when people say "React isn't a framework, it's just a library". Almost all of my React code is "called by React" with the one exception being `ReactDOM.Render()` (I don't count that since every other framework has some analogous "bootstrap" instruction).
Now if folks want to argue that React only handles the "view layer" without providing a built in state management solution, that's absolutely true (and considered a separation-of-concerns positive by a lot of people including me). But I feel like so many folks just boil this down to "React isn't a framework, it's just a library" and then use that as a segue to negatively comparing it with their chosen tool.
- rictic 5y agoAnd with hooks that's become even more true, there's now a distinction between React functions and regular JavaScript functions, and you can only call a React function from another React function.
- purplerabbit 5y agoNot entirely true. Hookless function components can be called as regular old functions just fine
- serverholic 5y agoIt stops being a library when you structure your entire codebase around it.
- betenoire 5y agoOr any part of your codebase for that matter
- dexwiz 5y agoI think React's original goal was to be a library, but the community made it a framework, because they could not conceive of any other way to operate.
- crate_barre 5y agoLess that they couldn’t conceive of any other way, but more so we are slaves to the vdom diffs. That’s what we signed up for, and boy did we get trapped. Go ahead, put a little jquery into your React app, or that animation library that looks cool, you’ll blow up the whole point of React. Sorry, you will have to do things React’s way until the end of time if you want your rendering to be optimal. That means whatever it means, hooks, suspense, fibers, context, so on. A library means I get to plug in other stuff without totally crippling another library, as React claims it is. Nothing wrong with React, just become the framework you are and provide the built in solutions. Think of it this way, imagine the React team made curl. Now they say you can curl anything. So now you say, ‘ok, I want to curl this’ and they respond: ‘Oooo, I don’t know about that, that’s gonna mess up all the curl internal optimizations, hmmm, no no, you SHOULDNT be curling that’ And then we all walk away going ‘oh’, silently. Checkmate, hoodwinked.
- szastamasta 5y agoHmm, I don’t really agree on this one. Just a day ago I’ve added a totally not vdom, stateful component that was mutating DOM and adding nodes on it’s own to fix performance problems with critical part of the app that required instant feedback to user typing. React was not bothered at all. From the start there were ways to escape React model in components and integrate components into other frameworks. Been there, done that, it was never a huge deal.
- crate_barre 5y agoCan you describe what you did? Breaking out of React for rendering means you are in deep shit. In fact, I’d love to see the hoops you jumped through, which I’m certain you will brush away as ‘not a big deal’. But I am an American, so I won’t put up with any inconvenience and don’t consider it virtuous to do so (we fought a war over a tea tax after all). But I’ll take a wild guess: A bunch of useRefs? I’m excited to hear all of this.
- notshift 5y ago
- Drew_ 5y ago> Almost all of my React code is "called by React" with the one exception being `ReactDOM.Render()` It only feels this way because your calls to React are hidden away behind JSX. I believe this is also why you can't write any JSX without importing the React module first. If you've ever had the "pleasure" of writing React with plain React.createElement() calls (what your JSX ultimately gets transpiled to) then I think you would more likely agree with the notion that React is "just a library". Create-react-app is much more akin to a framework in that it bootstraps an environment for you where you don't have to do any of the things that make React feel like simply a fancy library for rendering HTML.
- lugged 5y agoReact is a library that should have been a framework. Literally everyone has to cobble some n-factor framework together and given the amount of inexperience out there, what results is a damn nightmare. React solving the state problem natively would have made it an industry game changer. What we have is an industry mess.
- dragonwriter 5y ago> React is a library that should have been a framework. React is a library that powers several different frameworks, as well as lets people use it without those frameworks. If one size fits all, answer-for-everything frameworks were the optimal solution for all problems, Angular would own the world and we wouldn't need React.
- lugged 5y agoGoogle rug pulled angular, I know at least one very large company that pulled all Google tech from their stack over angular 1 -> 2. React really isn't the thing people have decided is the optimal solution, jsx and keeping presentation tightly coupled to business logic is. What is see with react is constant attempts to work against that ideal.
- dragonwriter 5y ago
- tshaddox 5y ago> > "you call a library, but a framework calls you." > This is why I don't like when people say "React isn't a framework, it's just a library" Eh, this is just a breakdown in the "framework calls you" heuristic. It's still a reasonable heuristic, but it doesn't completely describe all distinctions people make between frameworks and libraries. The distinction missing from the heuristic is the overall scope of the software project relative to other popular software projects in the same area. When people say "React isn't a framework, it's just a library" they're not saying much about the coding style one uses while using React. They're just comparing the overall scope of React to some of its close competitors (like Ember and Angular).
- mmis1000 5y agoIt used to try to be like that. Only calling setState re-renders things. And you control state and when to render. Until the hooks introduced. Now it also want to handles all the state and timing for update. And you are no longer able to call from outside or decides when to render (in a simple manner, as there are still workarounds).
- soruly 5y ago> "React isn't a framework, it's just a library" There may not be a clear line between framework and library, but as written in the homepage of reactjs.org, it claims itself: React - "A JavaScript library for building user interfaces"