Simple, 0 dependency class-based React view model for when you can't give up OOP
15 comments · 33% upvoted · source · other discussions
15 comments · 33% upvoted · source · other discussions
20 Years experience???
But this is just useState with extra steps...
Not all code is best described declaratively.
It would've been nice if you had shown an example that wasn't a setState(current => current + 1)
Id hate working with this guy
why
I might have been a bit mean there. But trust me. 60 percent of my work right now is cleaning up mess like this created by some backend dev who thinks frontend is just a dumb after thought.
React contrary to popular belief is very simple. Pulling shit like this doesn't only make it difficult to maintain but can introduce bugs and behaviors nobody thought about.
Just yesterday I had to fix dumb shit like
<div>
{getFooterComponent(date, links)}
</div>
They too had 20 years of experience . Put up a fight and had to finally point out the docs to them
So for me it comes from a place of frustration, you don't wanna do frontend don't do it.
jesus_christ_how_horrifying.jpg
you can just...use keys
if something isn't rerendering when the value is updating, throw a key on it comprised of the updated value which will cause that component and it's children to rerender
This seems... bad and hacky?
well if something isn't rerendering properly when it should, it's probably how the application is architected, but instead of introducing a whole new view model as a work around as this poster is suggesting, a key on a component marks it as being something to rerender/remount and what keys are actually designed for
if your key doesn't change, your component doesn't change
it's actually a common pattern in react, using keys to force revalidations, especially if you've worked with any of the query libraries
I laughed at the scenario because any dev with 20 yoe should be able to manage switching contexts between OOP and more functional patterns with ease.
cant_have_nicethings 3 points · Feb 2025
React is the “latest and greatest”. It’s going to be 12 soon.
murden6562 2 points · Feb 2025
This 1000%
macrozone13 2 points · Feb 2025
This must be satire, right? RIGHT?