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.
React is holding me hostage
81–90 of 553 posts
Re: React is holding me hostage
#82Earlier 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…
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
#83Earlier 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…
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
#84Earlier 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…
Re: React is holding me hostage
#85Earlier 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.
Re: React is holding me hostage
#86Earlier 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).
Re: React is holding me hostage
#87Earlier 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…
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
#88Earlier 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…
Re: React is holding me hostage
#89The 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…
Re: React is holding me hostage
#90Earlier 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
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.