D
D
DarthJS2018-09-19 12:08:13
OOP
DarthJS, 2018-09-19 12:08:13

What is the benefit in React + MobX + TS + OOP app architecture?

I have been working as a frontender for a long time, I worked with AngularJS , now with React more, but the bottom line is that most of the projects I worked with (although many were rather big ones), no one was sophisticated with them and did according to a simple best practices scheme, as evangelists from the Internet advise. But it so happened that the last couple of projects in the team are the majority, the so-called FULL-STACK gurus - these are the ones that actually dotnetchiki and screw the layout position: absolute everywhere.
Question on the front (in particular React ):
The lead rewrote the basic components of React , added his own rules and basic functions, including render,
now we write like this:

internalRender() {
        this.addCssClass(className);  // Этот классней приходит из пропсов
        this.addCssClassIf('required', isRequired); // этот метод тоже вместо тернарного оператора, если у нас вдруг что-то required
return (
  <Какой-то-компонент  className={this.renderCssClasses()} />
)
}

We also now have OOP , we no longer have a functional component , pure too, we now always inherit only from the miracle of invention.
Including, according to OOP rules, we now have a view, model, controller - which actually makes a huge component out of a small component and in three more files.
Attention, a question for connoisseurs!
What is the benefit of this approach?
What exactly is the advantage?
Personally, I still don’t see the usual React, I don’t see the advantages, the first thing that comes to mind is “how to make simple things complicated”.
It’s not the first time I’ve come across this, but the impression is that backend developers just want to write code the way they are used to.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavlo Ponomarenko, 2018-09-19
@DarthJS

What is the benefit in React + MobX + TS + OOP app architecture?

If you abstractly answer this question, then the profit is huge. MobX is a great framework and allows you to write maintainable code. Much better than the noodles Redax promotes.
If you delve into your example, everything looks strange. For example, this paragraph is completely incomprehensible to me:
React components are purely Views. There is no logic to make model components, because the whole model lies somewhere in the MobX area in files with the .ts extension. React is a view and the fact that they write the model and controllers in a view is weird.
In F.K. I personally don't see much point. Every application needs classic components. So why use two types of components when you can use one.
Pure pure (sorry for the taftology) is rare in React. Usually only in some small views. And pure as an end in itself is not really needed, unless you are chasing a temporary hype.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question