Live data from Hacker News

React is holding me hostage

emnudge.dev

31–40 of 553 posts

Re: React is holding me hostage

#32
post #27

I've been working on a React side project for a few months now and looking at my company's apps plus posts like this I think people just miss the point. Stuff like this: >Things get more complicated when you start using React Context and start signalling updates in a parent component. The render cascades. Maybe one component fetches some data, some component remounts, and you run your state update again, delayed by a…

The example you highlighted as "doing it wrong" is pretty typical for an autosuggest component: Input updates trigger some request, which propagates to some list somewhere else in the dom. As it's loading, a spinner is shown, but when results are retrieved, they're updated again. Throw in apollo to the mix or some other request library, and context is used.

Re: React is holding me hostage

#33
post #27

I've been working on a React side project for a few months now and looking at my company's apps plus posts like this I think people just miss the point. Stuff like this: >Things get more complicated when you start using React Context and start signalling updates in a parent component. The render cascades. Maybe one component fetches some data, some component remounts, and you run your state update again, delayed by a…

> Ultimately, React is f(newState) => UI. If that function isn't pure you're gonna have a bad time.

React is not that at all. Unless your UI is very simple, React is not f(newState) => UI. React isn't functional. More on that here: https://mckoder.medium.com/why-react-is-not-functional-b1ed1...

Re: React is holding me hostage

#34

I’ve happily used MobX for years. It comes with its own quirks but almost completely bypassed the awfully awkward state management that is React. Made my life 200% more enjoyable!

If you use Typescript, take a look at: https://mobx-keystone.js.org/

It's an additional layer on top of MobX that adds strong typing. I've been using it for an open source video annotation project and it's been amazing for keeping track of local state, cascading calculations of things.

Here's my "models" directory for it if you want a taste of how it works:

https://github.com/Rodeoclash/vodon-player/blob/main/player/...

Re: React is holding me hostage

#35
post #33
post #27

I've been working on a React side project for a few months now and looking at my company's apps plus posts like this I think people just miss the point. Stuff like this: >Things get more complicated when you start using React Context and start signalling updates in a parent component. The render cascades. Maybe one component fetches some data, some component remounts, and you run your state update again, delayed by a…

> Ultimately, React is f(newState) => UI. If that function isn't pure you're gonna have a bad time. React is not that at all. Unless your UI is very simple, React is not f(newState) => UI. React isn't functional. More on that here: https://mckoder.medium.com/why-react-is-not-functional-b1ed1...

You are both right. React components should render based on state that is managed by React, such that the rendered output changes only if the state changes.

The complicated bit is the handling of events and changing the state. Hence why you get Redux for state but there is no “Redux for views”

Re: React is holding me hostage

#36
Meh. The most important thing about React is you have to think like React wants you to. It's a very pattern-oriented type of development I haven't seen much of elsewhere.

Most of the footguns listed in this article are things you obviously shouldn't want to do because they're not React-y.

Re: React is holding me hostage

#37
post #33
post #27

I've been working on a React side project for a few months now and looking at my company's apps plus posts like this I think people just miss the point. Stuff like this: >Things get more complicated when you start using React Context and start signalling updates in a parent component. The render cascades. Maybe one component fetches some data, some component remounts, and you run your state update again, delayed by a…

> Ultimately, React is f(newState) => UI. If that function isn't pure you're gonna have a bad time. React is not that at all. Unless your UI is very simple, React is not f(newState) => UI. React isn't functional. More on that here: https://mckoder.medium.com/why-react-is-not-functional-b1ed1...

setState is a convoluted way of passing the newState to components.

useEffect is a side effect and if you use it you're gonna have a bad time.

Re: React is holding me hostage

#39

A side issue, but... can anyone tell me why people say "the orange site" instead of just saying Hacker News, as if it is a bad word or a secret?

They're just showing off their cleverness.

It's not even orange for me. I changed the "topcolor" in my profile settings to d0c8b5 - a darker shade of the body background color. Now the only orange thing is the Y logo. Much easier on my eyes this way.

Re: React is holding me hostage

#40
post #37
post #33

Earlier quoted context omitted.

> Ultimately, React is f(newState) => UI. If that function isn't pure you're gonna have a bad time. React is not that at all. Unless your UI is very simple, React is not f(newState) => UI. React isn't functional. More on that here: https://mckoder.medium.com/why-react-is-not-functional-b1ed1...

setState is a convoluted way of passing the newState to components. useEffect is a side effect and if you use it you're gonna have a bad time.

> useEffect is a side effect and if you use it you're gonna have a bad time.

Right.. but then you can't really use React for building serious UI.

Post reply on HN