Live data from Hacker News

React is holding me hostage

emnudge.dev

541–550 of 553 posts

Re: React is holding me hostage

#541

Earlier quoted context omitted.

I'm using React Native to build mobile games, and I am pleasantly surprised I can just write my own state management and update logic (hack around states and props) to walk around a lot of issues and get good performance.

If you hack around the state management and update logic, what is React bringing to the table? Just the cross platform widgets?

the rendering, which could easily be tied into the game loop. e.g. https://www.youtube.com/watch?v=uJRXJxsvj7Q

Re: React is holding me hostage

#542
How are you being held hostage? I'm currently using React, but I've used a lot of other frameworks in the past, and expect I'll be using a lot more in the future (Svelte is currently topping my list of frameworks to check out).

I started out in these sort of frameworks doing Angular 1 in 2013. Did a lot more Angular 1 projects in those years, and really got to know the intricacies of the framework. Was ready to switch to Angular 2, but instead I ended up doing some native JS web components, a little React, then some Vue, and now some serious React.

I've got to say, I liked the little React a lot more than the serious React. All those useEffects everywhere don't make the code any more readable. There's layers upon layers upon layers of components and abstractions and layers in between. It comes across as less organised than my old Angular 1 or Vue code did, though that's probably also due to the size of the code.

Anyway, I'm not being held hostage by anyone. Next project I hope to be doing something in Svelte, but maybe I'll end up doing something completely different. Maybe some Kotlin? I still haven't used that.

Re: React is holding me hostage

#543

Earlier quoted context omitted.

Just go and use the “new” Reddit. Take any metric you want from there.

The new Reddit is so slow... after some bingescrolling I often give up due to the annoying loading times and close the site. I always imagine that many people react like this on super slow websites, but on the other hand it's Reddit and many people don't know which site to visit instead :P

Try https://old.reddit.com

The day they disable it, I’m not using it anymore.

Re: React is holding me hostage

#544

Earlier quoted context omitted.

Rerendering on the backend can actually be faster than doing AJAX calls because the BE has to send a lot more data than if it's server rendered. I

How is "server rendered" different form "rerendering on the backend"?

Rerendering should be Rendering, however they aren't different. They are the same.

Server rendering can carry less of a payload to the FE but you aren't sending unnecessary data.

Re: React is holding me hostage

#545
post #196

Earlier quoted context omitted.

My position isn't that we should be using a new library per se. It's that we should be more selective about what 3rd party code we use and espescially what we ship to end users. React has tended towards a kitchen sink approach and this is exacerbated by initial design shortcomings/decisions i.e. no built in state management or method for encapsulating styles has lead to a deluge of libraries that promise to fill the…

Wait react is a kitchen sink approach but in the same breath you said it doesn't come with everything. Do you mean tended away?

Sorry, reading this back I see where that might be confusing. It's a few days later now but I think I was referring to React in the round as deployed in the real world, the community norms etc. rather than just the core library. In my experience the way that React projects tend to develop is that "tried and tested" libraries get added to to solve particular issues, most commonly state and styling (codified in meta-frameorks like NextJS etc.) but also UI transitions, wrappers around common non-react libraries like Leaflet or threeJS etc. The reason being that it's actually quite hard to sensibly integrate vanila JS libraries into a React code base so if someone has done the hard work why would you not use that. But of course this comes at a cost. More recent libraries (in my experience svelte but i understand this is a common feature) mitigate the issue by 1. having a builtin approach to state and styling 2. making it easier to drop down to the underlying HTML/CSS/JS without making a mess.

Re: React is holding me hostage

#546
post #192

Earlier quoted context omitted.

> I'm not sure I'd ever expect a framework, React or anything else, to stop that behavior. If a child component signals to a parent that the state has changed then I would always expect that to cascade down the node tree. That could cause further updates. And more renders. That behavior is on me. If the framework decided not to cascade some updates that would be weird. It's not that the properties shouldn't be update…

> Svelte just changes the relevant bit of the DOM, Because Svelte is mutable state galore. I thought we all agreed to say no thanks to that.

Yeah, but atleast in Svelte it's explicit, and you can if you wish write svelte as if ste were immutable. Anecdotal, but still, I've had fewer bugs (particularly wierd UI glitches) in Svelte than I ever did in React. I just like Svelte for the types of project I work on.

Tangent: the idea that "we all agreed to say no thanks to that" is kind of symptomatic of broader issues I have with web dev. i.e. that there's very little recognition that different tools have different uses and knowing when to pick which is part of the job. Working with wood you wouldn't apply the same practices and methods to building the timber frame of 2 story house as you would to making an intricately carved toy elephant. Why when working with the materials of the web, HTML/CSS/JS, do we assume there's a best and right why to do it: "you must write tests!", "avoid using z-index!", "separate content and form", "immutable state!"; these are all the right answer in some situation and not in others.

Re: React is holding me hostage

#547

Earlier quoted context omitted.

Is React good on mobile or does it just have a good solution there? I don’t think anything is stopping vue-native from popping up other than interest and someone to work on it.

TLDR: React Native sounds incredibly awesome until you are 5 years and 150 devs into it and realize that this shit sucks. But hey, if you are under 10 people and need apps everywhere, it is a nice thing.

Yeah, if you have a big team, everyone is going to be specialized anyways. You can have:

- Dedicated Android devs working on your Java/Kotlin/whatever Android app

- Dedicated iOS devs working on your Swift/Objective-C/whatever iOS app

- Dedicated web devs working on your JS/TS/whatever web app

- Dedicated BE devs working on your BE services, in 1-many languages that may be none of the above

But for startups, that’s not gonna happen, there’s gonna be wayyyy fewer devs and wayyyy less specialization. A lot of companies will be in that mode for many years, possibly indefinitely. In those situations, React Native can be a big win. I’ve been working the past 2 years at a relatively small startup, ~10 devs, that’s TypeScript everywhere. We’ve got 2 mobile apps (mobility space, a Rider and Driver app), both TypeScript/React Native/MobX. Rider is iOS/Android/web, Driver iOS/Android, very nice having 2 apps instead of 5. Then a web-only admin app in TS/React/MobX, and backend services in TS/Express. Same language everywhere, and similar mental model across all FEs, is a big productivity boon at our size.

Re: React is holding me hostage

#548

Earlier quoted context omitted.

You don't do that. Why would fetching data depend on whatever is being rendered? You know what data you need or not need before rendering anything, or you will be in a world of pain.

I am not sure I am following. Say your homepage has a link to a page that shows the top scorers in a league. Where/when does the fetching of the top scorers happen ?

Sure:

- Click the link to show top scorers

- Initiate fetching the data

- (The view may change to indicate you're loading the top scorers, if you want, that's a different matter).

- Receive the data, the view changes to display the data

This is opposed to:

- Click the link to show top scorers

- View changes to show top scorers component. A component loads, or mounts, or inits, or does something which triggers a data fetch

- Receive the data, the view changes to display the data

Your app "knows" you need the data when the user clicks the link, no need to involve the view components into this.

This gives you the ability of adding a lot of complexity to how you fetch the data that is best handled outside a UI component (like caching, reusing it in other components, error handling, retrying, throtling, whatever), while saving you from a whole class of problems where a misunderstood component lifecycle has consequences for your data. Frameworks like React or Angular are going to try to help you by caching outputs, reusing components, dropping updates for the same frame, prerendering, preloading or anything really. If you fetch data when a component does any of that, suddenly you have to care about it and fully understand it. The abstraction leaked. If you treat the component as close to a pure function as you can, things become much simpler.

This applies to relatively big, relatively complicated apps, controlled by a single entity, where it pays off to prioritize simplicity.

Re: React is holding me hostage

#549
post #280
post #50

Not to start an unholy flame war, but if you were to start a new project and didn’t need to worry about the ecosystem or workforce, what framework would you choose? Vue? Svelte? Something else?

Solid JS It will have a very easy learning curve for React users too.

Be careful on spreading the statement "easy for React users", yes that's true for using JSX, but for React developers trying out SolidJS, make sure not to desctructure props, get rid of rerending function mental model, components only runs ONCE so reactivity works by tracking reactive elements(signals/stores) inside JSX or effects(createEffect, createMemo ect), that means no early returns. If a React developer (I've witnessed this with Twitch streamers), jumps into SolidJS blind without taking tutorial, they get lost into rerender mental model.

Re: React is holding me hostage

#550

Earlier quoted context omitted.

I am not sure I am following. Say your homepage has a link to a page that shows the top scorers in a league. Where/when does the fetching of the top scorers happen ?

Sure: - Click the link to show top scorers - Initiate fetching the data - (The view may change to indicate you're loading the top scorers, if you want, that's a different matter). - Receive the data, the view changes to display the data This is opposed to: - Click the link to show top scorers - View changes to show top scorers component. A component loads, or mounts, or inits, or does something which triggers a data…

Okay, I get the idea. How are you solving these issues:

- how is the data fetch completion signalled to the component?

- how is the data piped into the component?

Would be happy to be pointed to some example code if you have.

Post reply on HN