0

From View.js:

In some cases, we may need “two-way binding” for a prop. Unfortunately, true two-way binding can create maintenance issues, because child components can mutate the parent without the source of that mutation being obvious in both the parent and the child.

I found it a little hard to understand the part in bold. How would you express this sentence in a native way?

  • I included the full paragraph into your question. So, this is about programming. If you are a programmer, can you say what the words binding, child, pattern and mutate mean in that context? Without knowing that, it's hard to even know what the text says. – Jan Jul 5 at 8:16
  • Do you understand Object-Oriented Programming? If not, there’s not really going to be a “native” way to express this. It’s jargon. – J.R. Jul 5 at 11:22
0

As noted in comments, this is a programming question more than an english language question. In programming jargon, just as in other fields, common words are used with sometimes very precise meanings, and these meanings may not reflect the common usage of that word.

A two-way binding is a connection between units that allows information to be passed in both directions.

Child components are units that sit below a parent component in a hierarchy and are grouped somehow under that parent, similar to a family unit (of people).

Normally one might expect that, when a task is passed from a parent component to a child component along with whatever information is required to perform that task, the child does whatever is expected of it - including changing (mutating) the information that is now under its control - but that when the task is finished, the information that the parent holds is still in its original form (unmutated).

However, when information is required to be passed back to the parent, or the changes (mutations) need to be applied elsewhere and are done so directly by the child (for whatever reason), then the risk exists that the child will mutate information, and then that mutation also applies to the information at the parent level, which is a behaviour that may not have been expected or anticipated.

Furthermore, the information that the parent now holds is the mutated version, and the parent has no copy of the original information, so no evidence of a change. Thus it may not be obvious that there has been a mutation.

Consider (in a pseudo-real-life context):

Two-way binding:

Parent receives child's report card.
Parent checks report card.
Parent sees child received an F grade.
Parent passes report card to child.
Parent asks for explanation.
Child checks report card.
Child changes F to A.
Child passes report card back to parent.
Parent checks report card.
Parent sees child received an A grade. (Parent has no memory of previous condition.)
Parent has no information that the grade has changed.

vs.

One-way binding:

Parent receives child's report card.
Parent checks report card.
Parent sees child received an F grade.
Parent passes a copy of report card to child.
Parent asks for explanation.
Child checks copy of report card.
Child changes F to A.
--- Child cannot change original report card!
Parent checks report card.
Parent sees child received an F grade. (Parent is looking at original, not the copy!)
--- Parent may be able to see that child changed grade (on the copy).
Parent still holds child's original, unchanged, report card.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.