News for hackers. Stuff that matters.
Re:Build your own web framework by wmfiv on Friday July 29, 2022 @12:17PM (#32278826)
I'm struggling with the idea that React is a primitive used to build a Web Framework.
Re:Build your own web framework by 0x457 on Friday July 29, 2022 @04:17PM (#32281336)
It's because almost no one uses React the way it was created, but ultimately depends on what you mean by Web Framework. I don't think react includes enough to be a web framework.

It's a library to make components for web pages. Notably, Facebook's chat window. Later, one people decides that it's a good idea to have one giant component mounted at `body` or `div` directly underneath the body that would hold everything else and even the sun.

React didn't have much for state management and doesn't have anything for navigation support. It was released in 2013 and Create React App, which is actually a framework, was released only in 2016. Even that isn't a framework, but rather a template.

Now, Next.js and Gatsby are actually frameworks based on React. Backbone.js is an MVC framework.

Re:Build your own web framework by jokethrowaway on Friday July 29, 2022 @07:37PM (#32282901)
I think the problem is that react is larger than several frameworks but provide 1/10 of the functionality.

If react were preact it would feel smaller and people who care about performance would embed it without thinking too much

Re:Build your own web framework by afiori on Saturday July 30, 2022 @08:06AM (#32286158)
I have seen it said as "React is neither a library nor a web framework, but a view framework"
Re:Build your own web framework by colordrops on Friday July 29, 2022 @12:27PM (#32278958)
I'm not a fan of React myself, but it's just a view layer. Or at least that's all it was when I last looked into it a few years back.
Re:Build your own web framework by leerob on Friday July 29, 2022 @12:43PM (#32279165)
You could swap out React here for another solution (e.g Svelte) and it would mostly read the same. The Build Output API[1] mentioned is how React, Vue, Svelte, and their "metaframeworks" run on Vercel today.

[1]: https://vercel.com/blog/build-output-api

Re:Build your own web framework by throw_m239339 on Friday July 29, 2022 @02:29PM (#32280285)
React can be used as a templating library server-side in a node environment (like handlebars). It's a bit heavy for the task but it works.
Re:Build your own web framework by crooked-v on Friday July 29, 2022 @06:04PM (#32282278)
A huge benefit React (and anything else that uses JSX) has over text-based templating is that you can strictly lint/typecheck JSX because ultimately it's just syntactic sugar over plain JS.
Re:Build your own web framework by likeclockwork on Friday July 29, 2022 @06:32PM (#32282492)
You can typecheck anything there exists a typechecker for.

Vue templates are typechecked for example.

Re:Build your own web framework by valbaca on Friday July 29, 2022 @12:41PM (#32279135)
React is "just" a library, it doesn't give you everything you need to build out a full-stack or framework.

For example, see Clojure's Luminus: https://luminusweb.com/

You have to dig down deep to find where React is.

Re:Build your own web framework by shepherdjerred on Friday July 29, 2022 @02:10PM (#32280092)
I think it’s easier to consider when you look at the frameworks that provide React + some other features. Of course you could swap React with something else, or write your own rendering + state management.

I think it’s similar to how Java web servers often use the library Netty under the hood. Why re-solve a problem?