Live data from Hacker News

React is holding me hostage

emnudge.dev

81–90 of 553 posts

Re: React is holding me hostage

#81
> It is not obvious that your component re-renders on state updates.

I... isn't it? Isn't this like the first thing in the hooks introductory material? If you don't find this, yeah, hooks are gonna be a bad time.

Re: React is holding me hostage

#82
post #47

Earlier quoted context omitted.

> ...and capture a sequential list of updates when you call setState. In functional programming, functions are not allowed to do that. The only thing a function is allowed to do is return a value. > ... you reach out up the stack to the component and store it there. FP functions are not allowed to do that. In FP functions can only rely on the parameters passed to it (it cannot refer to anything outside) and it should…

> In functional programming, functions are not allowed to do that. The only thing a function is allowed to do is return a value. Oh, yes, they are allowed to do that. You capture the effects into a list, and return the tuple of list and return value. If you feel like it, you wrap that into a monad to pretend you are only "returning" a single thing. > In FP functions can only rely on the parameters passed to it (it ca…

No matter how sophisticated the language we use to describe it: it’s still a bunch of side effects and state.

If you’re fetching some data in a useEffect you might not get a result that day.

If you’re updating something with setState, you are still managing state. UseState is a reference to a mutable object now.

You’re simply not getting the same answer every time your now impure function is called.

In order to do understand what’s happening you need to recreate the whole state. Which is exactly the same reason state management is hard as in OO or procedural.

You might have a mental model that explains why it is still FP, but for all practical purposes of that paradigm it isn’t.

Re: React is holding me hostage

#83
post #73

Earlier quoted context omitted.

All blow up events come from a loud and extremely small minority. But whether they are making noise or signal, does not depend on number of people! React continues to dominate others because it meets baseline criteria for a js framework. And has corporate backing while Vue doesn't. Angular 1 was also popular because it was average js framework with google's backing before angular 2. Implying that React remains popula…

> All blow up events come from a loud and extremely small minority. But whether they are making noise or signal, does not depend on number of people! Fair, this instance is 100% noise imo. We're engineers - we should be able to judge when something is silly. > React continues to dominate others because it has corporate backing while Vue doesn't. And angular was popular for the same reason before angular 2. I have nev…

You picked it because others before you had already decided and that was based off of the facebook name and backing. No one expected facebook to take such a pr hit over the last few years but ignoring why it become market leader misses the angular breakage event where everyone flocked from Google's framework to facebook's framework.

The reasons for not using other frameworks seems copycat without logic. For example vue uses v-for I don't want to have to learn a handful of obvious tags like v-if or v-else but then choosing react which has adopted jsx something that requires converting standard html and learning more to get you to the same place.

Re: React is holding me hostage

#84
post #73

Earlier quoted context omitted.

All blow up events come from a loud and extremely small minority. But whether they are making noise or signal, does not depend on number of people! React continues to dominate others because it meets baseline criteria for a js framework. And has corporate backing while Vue doesn't. Angular 1 was also popular because it was average js framework with google's backing before angular 2. Implying that React remains popula…

> All blow up events come from a loud and extremely small minority. But whether they are making noise or signal, does not depend on number of people! Fair, this instance is 100% noise imo. We're engineers - we should be able to judge when something is silly. > React continues to dominate others because it has corporate backing while Vue doesn't. And angular was popular for the same reason before angular 2. I have nev…

"Doesn't reinvent the wheel" they literally created a whole new language called JSX, I have 13 years writing JS and I dislike React and JSX is one of the reasons. As far I can tell reason it's picked a lot of times now it's market share, people see that is more popular than the competition so they try to learn it, creating a feedback loop that just makes it more popular.

Re: React is holding me hostage

#85
post #75

Earlier quoted context omitted.

Forms are absolutely a problem, though. Forms not being "reacty" isn't going to get you out of needing them.

As react is only the core library and not a batteries-included framework, you will often find additional libraries that help with certain use-cases. E.g. if you are dealing with forms a lot, I would strongly suggest using react-hook-form or formik.

If it's not batteries included if should not require people to add a huge amount of overhead to their projects to use it, stuff like JSX or create-react-app

Re: React is holding me hostage

#86

Earlier quoted context omitted.

The bit of react that is f ( newState ) => UI is the easy part. The bit that is g ( state , userInput ) => newState is the hard part. In particular managing the scope of that newState . Oh, and sometimes you need to handle h ( state , asynchronousData ) => newState too. And then comes the fact that even though your f is _pure_, it also has to be _fast_, because it's going to run every time you get a newState .

In my experience redux-toolkit + redux-saga for async stuff usually work really well. In case of performance problems one can go with profiling + targeted optimisations (e.g. a separate store, some locally managed state).

I had to rescue a redux-saga project that went badly off the rails. It was one of the most inscrutable and difficult to debug codebases I've ever had to work with. Forget completely about ever having a usable stack trace.

Re: React is holding me hostage

#87
post #47

Earlier quoted context omitted.

> ...and capture a sequential list of updates when you call setState. In functional programming, functions are not allowed to do that. The only thing a function is allowed to do is return a value. > ... you reach out up the stack to the component and store it there. FP functions are not allowed to do that. In FP functions can only rely on the parameters passed to it (it cannot refer to anything outside) and it should…

> In functional programming, functions are not allowed to do that. The only thing a function is allowed to do is return a value. Oh, yes, they are allowed to do that. You capture the effects into a list, and return the tuple of list and return value. If you feel like it, you wrap that into a monad to pretend you are only "returning" a single thing. > In FP functions can only rely on the parameters passed to it (it ca…

Wow, I've never seen a reply that so thoroughly fails to address any of the points it's trying to reply to.

When you reply to "in FP, functions cannot do that (change state anywhere)", you say "you are allowed to do that: capture the effects into a list, return the tuple of list and return value" without realizing you're saying exactly the same thing?! The distinction between "return value" and "return value plus some other thing" does not exist. What matters is that the function's only observable modification is in what it returns, be it one value of many. This is basic FP.

Re: React is holding me hostage

#88
post #73

Earlier quoted context omitted.

All blow up events come from a loud and extremely small minority. But whether they are making noise or signal, does not depend on number of people! React continues to dominate others because it meets baseline criteria for a js framework. And has corporate backing while Vue doesn't. Angular 1 was also popular because it was average js framework with google's backing before angular 2. Implying that React remains popula…

> All blow up events come from a loud and extremely small minority. But whether they are making noise or signal, does not depend on number of people! Fair, this instance is 100% noise imo. We're engineers - we should be able to judge when something is silly. > React continues to dominate others because it has corporate backing while Vue doesn't. And angular was popular for the same reason before angular 2. I have nev…

AngularJS and Angular (what you referred to as Angular 1 and 2) are completely different frameworks. It’s a branding issue, not a technical one. Angular, from version 2 to 15 in the past 8 years, has been completely backwards compatible, and even stayed on the same paradigms. Angular code from 8 years ago looks almost the same as modern code. Which is much more stable than react’s codebase.

Re: React is holding me hostage

#89

The snark is strong with this one. It's a pretty major rant, without putting forward an alternative. The only viable alternative for me personally is VueJS and that's not my cup of tea either. I like React. It makes sense mostly. Is React perfect? No. Do I like React's recent transition to focus server side? No. But the problems it addresses are tough to solve. Show me a better solution and convince me its tangibly b…

It's reasonable to highlight issues without presenting alternatives. If a valid alternative existed, people would have moved already and this type of post wouldn't exist.

Re: React is holding me hostage

#90
post #75

Earlier quoted context omitted.

As react is only the core library and not a batteries-included framework, you will often find additional libraries that help with certain use-cases. E.g. if you are dealing with forms a lot, I would strongly suggest using react-hook-form or formik.

If it's not batteries included if should not require people to add a huge amount of overhead to their projects to use it, stuff like JSX or create-react-app

> create-react-app

That's neither required, nor being recommended by the wider community anymore.

> JSX

JSX on the other hand I feel like is something that is essential to React (yes, I know that some people disagree), and one of the few things it should provide/require, as it forms a cornerstone of it's UX. Getting things set up to understand JSX/TSX has been smoothed out a lot now, and hasn't been an issue in any greenfield project I have set up in the last 2-3 years.

Post reply on HN