10 ms·
React Labs: What We've Been Working On – February 2024
- hyfgfh 3y agoSo thats why CRA has been left to die?
- dgellow 3y agoWhat is cra?
- preommr 3y agocreate react app: https://create-react-app.dev/ https://create-react-app.dev/
- deleted 3y ago[deleted]
- azangru 3y agoWhat's the connection? Also, take a look at this response from 2021: "Like I said earlier, it was always the intention that we're not going to be able to work on it full-time... [I]t was intentionally designed for this kind of sporadic development. We would get critical fixes out as soon as posible, but overall, starting with 2.0, it's mostly in maintenance mode and does not strive to be the best tool for production React apps. It is a tool to get started and get something running fast. Perhaps, it's not even best at that anymore." https://github.com/facebook/create-react-app/discussions/11768#discussioncomment-1817264 https://github.com/facebook/create-react-app/discussions/117...
- hyfgfh 3y agoA new solution could replace some of the tools we use today, making it obsolete and not worth maintaining in the future. Make sense, but the lack of an "oficial" solution doesn't help https://react.dev/learn/start-a-new-react-project https://react.dev/learn/start-a-new-react-project
- gardnr 3y agoI have been tempted to go back to turn of the century tech: html tables for layout with inline css for styling and smarty template for separation of concerns all driven by php.
- azangru 3y ago> html tables for layout with inline css for styling Html and css have only been getting better over the past two decades; they are not the problem; no need to resort to inline styles and tables. As for going back to server-side templating with php, this is a very good option.
- fabian2k 3y agoCRA was never a fully official project, though there was a lot of confusion around that. It was in a weird semi-official state, it certainly had the endorsement of the React team initially but it didn't have actual resources from Meta behind it. CRA was useful when it first appeared because the whole space was a big mess. But it very quickly outlived its usefulness, and its approach was really problematic in my opinion. The config was too complex to eject and modify compared to what you could do yourself with Webpack directly.
- rozularen 3y agoI mean, the CRA repo is under facebook org in github
- unkulunkulu 3y agomy 2c: still does the job without ejecting on my small project. Just reading your comment made me happy I don’t spend time thinking about webpack configuration
- fabian2k 3y agoUntil you run into any problem that you need to debug with the build process. And there are more problems today because CRA is not maintained well now. The tools got much better, it's much easier to just set up a basic Webpack or Vite setup today compared to when CRA was originally created. And the simple configs are much simpler to debug and understand when something doesn't work as expected.
- unkulunkulu 3y agothank you, will keep this in mind if problem arises, maybe the best route would be to reset the build system
- hyfgfh 3y ago> CRA was useful when it first appeared because the whole space was a big mess. But it very quickly outlived its usefulness, and its approach was really problematic in my opinion. The config was too complex to eject and modify compared to what you could do yourself with Webpack directly. Yes agree, but writing and marinating config for multiple projects just don`t scale. Not to mention we need something dirty and fast.
- tiborsaas 3y agoI recommend Vite starter templates: https://vitejs.dev/guide/#scaffolding-your-first-vite-project https://vitejs.dev/guide/#scaffolding-your-first-vite-projec...
- madmaniak 3y agoMemoizaition - since over 10y in imba.io. Just sharing.
- omeid2 3y agoI have been using React at least since 2017 so not a hater; but how many version are we away from elm at this point? https://elm-lang.org/ https://elm-lang.org/
- Couto 3y agoReact was closer to elm during the times of stateless functions and redux. Since then it's getting further apart from elm. Redux was kinda of a poor man's elm but it got the right principles. However the JS community hates boilerplate code so, new, more complicated abstractions appeared. Also, it was too easy, with redux, to shoot yourself in the foot. Since then, with hooks, things are just getting harder and more complicated in my opinion.
- omeid2 3y agoThe newish `useReducer` is basically redux but tied into react like in elm.
- satvikpendem 3y agoI'm assuming you mean `useReducer` with `useContext`, but note that they are not a replacement for Redux: https://blog.isquaredsoftware.com/2021/01/context-redux-differences/ https://blog.isquaredsoftware.com/2021/01/context-redux-diff...
- omeid2 3y agoThat article makes a lot of hand-wavy assertion and makes up strange definitions. userReducer, specially with useContext does absolutely replace Redux and provide mechanism for state management. The article is, in short, just wrong.
- satvikpendem 3y agoThe main point is here: https://blog.isquaredsoftware.com/2021/01/context-redux-differences/#context-and-usereducer https://blog.isquaredsoftware.com/2021/01/context-redux-diff... Context updates all components while Redux and similar state management tools, because they live outside of React, do not. That's the main reason to use true state management tools over context. If you have a relatively small application or you don't care about that, continue using context. The article is also by a Redux core maintainer so you might call that biased but they know what they're talking about, since they're privy to React design decisions much more than regular users.
- udbhavs 3y agoLearning about the auto-memoization feature when it was called React Forget made it seem like a pretty natural extension of the functional component paradigm - separating out and memo’ing parts within components based on info that’s trivially available at compile time (maybe not trivial, I’m not sure how much work is being done by the compiler here). Is this something that could be implemented as a language-level feature for some “dedicated” language for writing functional reactive UIs? Languages like ReasonML are meant to map more nicely to React’s model because of their expressiveness, but I wonder if it could be taken further.
- preommr 3y ago> One way to think about this is that React currently re-renders when object identity changes. With Forget, React re-renders when the semantic value changes — but without incurring the runtime cost of deep comparisons. There's got to be another word for 'magic' to describe this kind of behavior because this is on a whole other level. People complain about observers, or transpiling being too magical, but at least those are straightforward in principle. I can see Rich's video on how svelte works and more or less get it, it's just that it happens implicitly. Semantic value here would depend entirely on the data type; I have no effective way of being sure of what is being implicitly generated.
- diggan 3y ago> There's got to be another word for 'magic' to describe this kind of behavior because this is on a whole other level As far as I understand that quote, it's just about "reference equality" vs "value equality", something most programmers deal with often but maybe frontend programmers aren't used to it? Not sure why the quote doesn't include that naming for it, maybe it would help people connect it to concepts they already understand. FWIW, I also think React has gotten to complicated and bloated, but I've been thinking that since hooks were introduced if not before, and mainly use React indirectly via Reagent, not directly.
- egeozcan 3y agoThe problem is a library changing language semantics mostly as a consequence of their own earlier design decisions. So I can totally explain someone how there is no pass-by-reference in Go, and I can also explain why equal sets of different identity are not really equal in JS (following the records proposal, with my fingers crossed, and happy with it because it's a language change), but when libraries introduce different semantics via their own compilers, that's a line I don't like getting crossed. That's actually why I never really got into Svelte.
- CharlieDigital 3y agoEvan You (Vue author) had a great quote about this: A mutable model that you can reliably understand is better than an immutable one that leaks. The pain and suffer of hooks all roots from the mismatch between a dogmatic belief in the superiority of immutability and the harsh reality of the host language that is JavaScript. React's render cycle is fundamentally mis-aligned with JavaScript since the re-render requires that you correctly manage state and references in the path of the render cycle by moving it out of the way with a hook. It all feels quite unnatural as someone who has been writing JavaScript since the last 90's. https://twitter.com/youyuxi/status/1629636673519894528 https://twitter.com/youyuxi/status/1629636673519894528 https://twitter.com/youyuxi/status/1629636967473496064 https://twitter.com/youyuxi/status/1629636967473496064
- throwaway220033 3y agoThe goal behind "hooks" was to make React simpler for beginners. I build client-side apps since 2007, and React is getting too magical and complex for even for me. The NextJS influence is really making things worse, "use server" "use client" tags do not scale at all. The project clearly lacks mission, goal, leadership and direction. I'll use Preact in the next projects.
- iamflimflam1 3y agoCan't help but agree. It's very hard, even for experienced developers, to understand what is going on with hooks. Even knowing why they are needed requires a deep understanding of what is happening. Definitely feels like complex implementation details leaking upwards and influencing the public API.
- pavlov 3y agoPersonally I appreciate the ideas behind hooks, but the implementation feels like I’m trying to write in a different language behind JavaScript that has its own rules about scope, flow control, variable dependencies, and many other things that run counter to what appears to be happening on the JavaScript surface. I’ve worked on many projects that implemented object-oriented programming in C, and the impedance mismatch there was much more tolerable. That should be a warning signal that something is amiss with hooks in JS. They made an embedded language extension for JSX. Why not a similar separate language for hooks, to clearly delineate when you’re working with the React state machine rather than ordinary JS state?
- _heimdall 3y agoWhen hooks were first announced they had a bit of a "you probably shouldn't use this unless you're framework author" air to them. I'm not sure if it was the react team adjusting the message and pushing for hooks in user code, or users throwing hooks at every problem when that wasn't recommended, but it definitely got odd track. I still like hooks for internal code in libraries and frameworks, but they ruin client code IMO. Unfortunately hooks are here to stay and there's really no way to avoid them in most apps today.
- 3y ago
- cal85 3y agoCan anyone clarify how the compiler would fit into the workflow? Are we talking some kind of CLI that takes a JSX/TSX entry point as input and outputs a compiled JS bundle, like a replacement for Webpack/Rollup etc. but more specialised to optimise React code? Or something more fine-grained that operates on a single component/module at a time? Or something else?
- Rapzid 3y agoMobX and chill. No compiler necessary. If React created better extension points for pluggable reactivity we wouldn't even need observer() wrappers. This is all getting kinda bonkers.
- sesm 3y agoMobX re-introduces all push-reactivity problems that React removes.
- machiaweliczny 3y agoIt can do it but not necessarily. I think in strict mode only actions can modify state and if you use reactivity only for rendering then it great
- Rapzid 3y agoCan you elaborate on this? React's in-built reactivity system via props and context are certainly push. I'm not even aware of a pull-based reactivity system.
- sesm 3y agoReact developers wrote about this here: https://legacy.reactjs.org/docs/design-principles.html#scheduling https://legacy.reactjs.org/docs/design-principles.html#sched... Let me try to explain this differently: A typical reactive framework architecture (RX, Knockout, etc) looks like this Events -> Observables -> Computed values -> Subscriptions -> DOM updates It aims to provide a targeted DOM update in response to event as soon as possible, but it has several major disadvantages: 1. Batching and prioritizing capabilities either don't exist, or are limited and generic, in particular by default they are not tied to UI structure, because the framework itself doesn't want to be aware of UI structure, it just wants the framework user to provide event sources and write update targets manually. 2. Computed values are computed if corresponding subscriptions are active. In contrast, React hides state propagation logic inside the component tree, so the computation happens only when components are actually rendered. Issue 1 is not relevant for MobX-React case, because React is doing UI update batching and prioritisation. But issue 2 is very real, especially when using React Router. I had multiple cases where Computed values were computed at unexpected point in time and used observable values that were not initialised, while corresponding React components were not even visible on the screen.
- mewpmewp2 3y agoI don't think React is approachable. It is just the most popular framework and has the biggest ecosystem, that is why it is used. Otherwise it is just not good in my view compares to others. Also I don't think useMemo or useCallback were a reasonable compromise ever.
- larodi 3y agoReact like angular seems to me very much a solution from a bygone time. The time when internet was slow and expensive. I find very little reason for anyone, except services in the insta scale, to actually use this abomination, since CSS and html deliver the same user experience with plain SSR.
- addicted 3y agoThe internet is still slow and expensive for huge swathes of the world. React is still not a better option for them. The truth is that React was very good and probably would have remained pretty good to great even today if the original form had been iterated upon. What we’re seeing today is nothing like the original react and should have been a completely different library in the first place. I suspect if this completely library had been created without the advantage of piggy backing off the original highly successful React library’s fame, it would have made little to no headway on its own strength. Heck, I’d be open to an argument that what we’re seeing today, a DSL that’s focused on making NextJS work, could even be considered a 3rd or 4th different library under the React moniker, after original React, hooks based React (even here the goal and meaning of hooks changed midway) and then the current NextJS DSL.
- zarzavat 3y agoI get that some people only work on web pages, but can we at least have some acknowledgement that web apps exist? Some people (me) use React to build interactive web apps. That’s what it was designed for, and it works rather well. SSR is completely useless for me.
- sesm 3y agoIt became the most popular in the landscape where all kinds of other frameworks existed. Because nothing beats immediate-mode-style API in terms of code clarity.
- Karupan 3y agoIt’s getting harder to keep track of all the shiny new features. UI devs already deal with TS->JS compiler, tailwind compiler just to name two. Can’t imagine adding another compiler to the mix. Our already complex and fragile build pipelines just keep getting worse. I understand the problems in scaling UI development. Just don’t think the solution is to build another layer of complexity atop the shaking foundation.
- diggan 3y ago> Just don’t think the solution is to build another layer of complexity atop the shaking foundation Why would we try to solve UI development issues any different than other parts of the stack? Building layers on top of shaky foundations is a true and tested approach in computer science and seemingly the only way to move forward somewhat.
- deleted 3y ago[deleted]
- throwaway2990 3y agoAt this point people should already be looking to move away from react to something better like svelte, Vue, htmx. Why anyone would start a project with react in 2024 be beyond me.
- Cthulhu_ 3y agoFor crossplatform mobile development, the only viable solutions in 2024 are React and Flutter, and the former has a wide ecosystem already while the latter uses a programming language, framework, and ecosystem only used in that particular use case.
- _heimdall 3y agoAll these features sound interesting in isolation, but I can't help thinking that react is stuck on the same treadmill its been on for years. They keep solving important problems like memorization bugs, but these problems are all self inflicted. The API keeps getting more complex, and with a goal of backwards compatibility everything is additive. Actions as a generic concept look interesting, but the idea of having every library expose both onSubmit and submitAction is just going to make things more confusing. I guess you use events for old code, and actions when you want the option to send the event to the server depending on the "use server" directive or pragma? And when the next thing comes along, I guess every library exposes 3 different ways to handle a form submit event?
- geobourazanas 3y ago[dead]
- martpie 3y agoLots of valid points about the increase in complexity for React over the years, and that one should pick another more modern tech stack (Svelte, Solid, html, whatever), and I used to be thinking like that But since maybe 1-2 years, I am back and betting on React for most of my serious projects (for the ecosystem, the ease of hiring, etc), but the most important point is the following: React backwards compatibility is really good, and will stay so for a good reason: a LOT of Meta’s UI code is using old features (classes syntax etc), and Meta cannot afford to break those. If there are breaking changes, they must be “codemodable” (so, usable by everyone). Meaning in terms of stability, I know my codebase today will still work fine in years ( or upgrade-able with minimal efforts). Of course there will be new shiny features, but I or my team will not have to rewrite old code all the time following tedious migration guides. disclaimer: I am kind of biased as I work at Meta, but far from React.
- gardnr 3y agoSo, your team upgraded to React 18 without having to rewrite anything?
- Cthulhu_ 3y agoThe person you're replying to did not say that, you're arguing against a straw man. Looking at the manual, upgrading to 18 seems straightforward, matching the "minimal efforts" they mentioned: https://react.dev/blog/2022/03/08/react-18-upgrade-guide https://react.dev/blog/2022/03/08/react-18-upgrade-guide
- gardnr 3y agoArguing isn't the correct word for that. I did express incredulity when asking for clarification. The person I was replying to did minimize the effort involved in upgrades by enclosing it in parentheses. The incredulity is based on experience. Sure you can follow the upgrade guide, and if you work at Meta there are many people that know about weird edge cases. If you don't work at Meta, then you may be spending time chasing down bugs in production on your own. That gets expensive.
- mrcino 3y agoJust use CLJS with Reagent, we had memoization out of the box for a couple of years...
- nesarkvechnep 3y agoI've heard great things about ClojureScript. My only problem is I don't want to have to touch the JVM.
- deleted 3y ago[deleted]
- argentinian 3y agoI like about Vue that everything feels straightforward and if fits in my head. In other words I think it's powerful and at the same time simple. It had only once a big change, and even then it was very easy to understand. If you knew the options api, the composition api was very easy to understand. Maybe Svelte is also like Vue, I haven't tried it. I've heard many react horror stories but I've never used it, so I don't know how true they are.
- satvikpendem 3y agoFor some reason, I see people in this thread whom I believe don't really understand why hooks were invented. Put simply, just like closures hold state in a function, hooks compartmentalize the component's lifecycle, they are basically `function(state, lifecycle)`. I linked to a Flutter thread elsewhere (on the topic of adding hook-like constructs to Flutter as well) that I've seen as one of the best examples of why class components simply cannot replicate the effects of hooks, due to the inherent limitations of classes [0]. The author uses an example of needing to initialize and dispose of a variable, and you must do this manually each time, for each variable. With a hook, you can abstract this behavior and say, given this lifecycle, I need this variable to be automatically initialized and disposed at the correct time. I write it once, and don't have to think about doing it manually anymore. Hooks are an abstraction over lifecycles, just as functions and loops are an abstraction over repeated procedures. [0] https://github.com/flutter/flutter/issues/51752 https://github.com/flutter/flutter/issues/51752
- cooperadymas 3y agoI am certain your comment was well intentioned, but it is quite striking how frequently the you are arguing against it, so clearly you must be an idiot defense pops up any time someone criticizes React[0]. [0] https://news.ycombinator.com/item?id=35278169 https://news.ycombinator.com/item?id=35278169
- satvikpendem 3y agoI'm not saying they're an idiot, but it takes time to learn tools. Frontend devs and React devs in particular are usually more novice than other types of coders (in my experience), likely due to so many courses pushing out MERN devs over the last 10 years or so, so it is very likely that most just went with the flow and never actually sat down to read the docs and understand their tools.
- notpachet 3y agoIsn't this an implicit argument in favor of simpler tools with less thorny undersides than React Hooks?
- JackMorgan 3y agoA lot of throwaway accounts on here recommending people switch to vue in 2024. At least for now, I don't see any urgency to switch from React. There's more React developers than Vue, Angular, Svelte, htmx, and Solid combined. React is not quite as ergonomic as Vue or Svelte, but all are swiftly approaching feature parity. Vue and Sevlte don't seem to represent a big enough boost in productivity to justify rewriting an entire generation of codebases.
- Cthulhu_ 3y agoTo latch onto this comment; never switch an application's primary framework for the sake of switching. Consider other things, like time spent maintaining, hiring, training and onboarding required, support, etc. Anecdote, we switched to React Native from a thing called Nativescript, primarily motivated by the dwindling development and support, and the huge overhead that Nativescript brought. But I have to hold my hand up and say I didn't like Angular and the redux-style beating around the bush either.