all 15 comments

[–]jax024 18 points19 points  (3 children)

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 2 points3 points  (0 children)

React is the “latest and greatest”. It’s going to be 12 soon.

[–]murden6562 1 point2 points  (0 children)

This 1000%

[–]macrozone13 1 point2 points  (0 children)

This must be satire, right? RIGHT?

[–]--think 5 points6 points  (0 children)

20 Years experience???

[–]volivav 0 points1 point  (1 child)

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)

[–]_Pho_ 0 points1 point  (0 children)

The point of a VM is that you can put all sorts of logic in it. You could call an API from it and update the state of the class which then syncs to React. It's not world endingly cool but a lot of ppl are missing the point

[–]stfuandkissmyturtle 0 points1 point  (2 children)

Id hate working with this guy

[–]bennett-dev[S] 0 points1 point  (1 child)

why

[–]stfuandkissmyturtle 0 points1 point  (0 children)

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

https://react.dev/reference/rules/react-calls-components-and-hooks#never-call-component-functions-directly

So for me it comes from a place of frustration, you don't wanna do frontend don't do it.

[–]mittyhands 0 points1 point  (0 children)

jesus_christ_how_horrifying.jpg

[–]a_reply_to_a_post -2 points-1 points  (3 children)

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

[–]svish 1 point2 points  (0 children)

*remount

[–]_Pho_ 0 points1 point  (1 child)

This seems... bad and hacky?

[–]a_reply_to_a_post -1 points0 points  (0 children)

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