I started learning React for starting a large project a few months ago. I have not really liked the experience very much. One seems to still need to know all the JS/CSS/HTML I've been using for 10+ years but also a new stack on top of it, simultaneously. Hooks are one of the strangest features I've seen in a language yet. I doubt they will be a lasting paradigm outside of the React ecosystem. I like JSX a lot. The id…
Best way to debug react is to do it via your IDE debug functionality, to enable debugger on caught errors (if you get errors in other code you usually can blackbox it) or to utilize `debugger;` command. Don't forget browser extension for cases where no error happens.
Algebraic Effects for React Developers
31–40 of 98 posts
Re: Algebraic Effects for React Developers
#32I started learning React for starting a large project a few months ago. I have not really liked the experience very much. One seems to still need to know all the JS/CSS/HTML I've been using for 10+ years but also a new stack on top of it, simultaneously. Hooks are one of the strangest features I've seen in a language yet. I doubt they will be a lasting paradigm outside of the React ecosystem. I like JSX a lot. The id…
Something is off with your transpiling set up if you’re not getting accurate stack traces. A “create react app” default setup will should have accurate stack traces out of the box. To your point about best practices React, at least at the beginning was not supposed to be the entire stack, by design you needed other libraries to deal with large portions of the web state and as such it could only control a small part o…
The stack traces are truly and utterly useless. One cannot see what triggered a rerender or other reactive action.
And a rerender can be triggered between two lines of synhronous code, magically, thanks to es6 proxies. What have I done???
Re: Algebraic Effects for React Developers
#33Hooks are not functional. The most elementary rule of functional programming is no state and no side effects. If you break these rules and justify your rule-breaking by pointing to esoteric concepts then you're violating the spirit of functional programming. Thanks to React Hooks a whole generation of JavaScript programmers are being misled into believing they are doing functional programming when they're really not.…
Why is that important?
Re: Algebraic Effects for React Developers
#34Hooks are not functional. The most elementary rule of functional programming is no state and no side effects. If you break these rules and justify your rule-breaking by pointing to esoteric concepts then you're violating the spirit of functional programming. Thanks to React Hooks a whole generation of JavaScript programmers are being misled into believing they are doing functional programming when they're really not.…
The fact that each time you call useState in a render method you get back a different value should be a clue.
You have to have a fairly sophisticated/twisted mental model of a react component’s function signature as effectively including each of the hooks it requires to be able to mentally model hooks as pure functions.
Hooks are a clever imperative hack that works only if you stay in the strict subset of JavaScript behavior that react expects, but which lets you get the benefits of some algebraic-effect-like contextual handling that would be easily expressed in a functional syntax, but they’re not functional.
Mind you, an OO person might equally say they are an imperative hack to get you the benefits of dependency injection that would be more easily expressed in an OO syntax, but they’re not OO.
What hooks are is more ‘imperative reactive’, I would suggest.
Re: Algebraic Effects for React Developers
#35Earlier quoted context omitted.
>"One is because it's the right tool. " Yeah sure. You choose the right tool because it it the right tool. >"The second is to do with the JS tech battlefield - you pick React because it won the front-end popularity fight" If we always pick "most popular" there will be only one left. >"you can hire React developers, and you can hire them knowing they will want to stay React developers etc." I guess some big companies…
I agree with you on all these points! However the "market" behaves the way it behaves (in general), and we need to try to avoid the 99% of it.
Re: Algebraic Effects for React Developers
#36Hooks are not functional. The most elementary rule of functional programming is no state and no side effects. If you break these rules and justify your rule-breaking by pointing to esoteric concepts then you're violating the spirit of functional programming. Thanks to React Hooks a whole generation of JavaScript programmers are being misled into believing they are doing functional programming when they're really not.…
Re: Algebraic Effects for React Developers
#37Earlier quoted context omitted.
I too can't shake the feeling that hooks are off. I like JSX and the component model. In React and like-minded projects, I look at a stack trace and see that it starts at some kind of batch renderer. I can't tell "why", "how" or sometimes even "what" broke. The input part of it is completely lost. I work on a Backbone application where stack traces are much more obvious. They usually tell you the whole story. I find…
> I too can't shake the feeling that hooks are off. Well the alternative to hooks is componentDidMount, componentDidUpdate, etc. It's a lot easier to sync state and UI when the logic for doing so can be put in one place.
The debugging story isn’t great if you expect to be able to use breakpoints.
It’s all about putting console.log wherever really.
The beauty comes in the speed of coding, I can move so fast that I always build a mock version of my api layer and can have the entire UI done rapidly.
Re: Algebraic Effects for React Developers
#38Earlier quoted context omitted.
Something is off with your transpiling set up if you’re not getting accurate stack traces. A “create react app” default setup will should have accurate stack traces out of the box. To your point about best practices React, at least at the beginning was not supposed to be the entire stack, by design you needed other libraries to deal with large portions of the web state and as such it could only control a small part o…
I’m wondering if part of the problem is that I’ve made a poor life choice in making this library the central state manager in a large app: https://github.com/RisingStack/react-easy-state The stack traces are truly and utterly useless. One cannot see what triggered a rerender or other reactive action. And a rerender can be triggered between two lines of synhronous code, magically, thanks to es6 proxies. What have I do…
All you need is a simple layer to make your typed api calls.
export const ApiService = {
return {
getSomeStuff: async () => ...,
postSomething: ...,
etc,
};
}Re: Algebraic Effects for React Developers
#39I started learning React for starting a large project a few months ago. I have not really liked the experience very much. One seems to still need to know all the JS/CSS/HTML I've been using for 10+ years but also a new stack on top of it, simultaneously. Hooks are one of the strangest features I've seen in a language yet. I doubt they will be a lasting paradigm outside of the React ecosystem. I like JSX a lot. The id…