A
A
aivazovski2019-04-19 06:53:01
React
aivazovski, 2019-04-19 06:53:01

Is the use of the toComponent method part of a convention?

Hello.
I'm sorting out someone else's project here, and almost everywhere I stumble upon the "toComponent" method, in which the node returns data about entities. For example like this:

...
toComponent () {
        return {
            list: this.history.map(h => ({
                id: h.id,
                dateCreate: h.dateCreate,
                operation: moderatorOperations[h.operation],
                comment: h.reason,
                moderator: this.users.get(h.moderatorId),
            })),
        };
    }
...

Judging by the git, different pieces were written by different programmers, but everywhere toComponent.
I want to ask if this is part of some well-known agreement or is it a local trick? If this is a general convention, what does it sound like and when should such a method be used?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Robur, 2019-04-19
@aivazovski

The fact that different programmers in one project wrote the same thing is a sign of a good project and good programmers. Or in the project it was accepted explicitly, then this agreement for the project or so it happened and it simply does not change.
"In general" there is no such agreement, and indeed there are quite a few general practices outside of those recommended in the docks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question