2

According to this salesforce developer blog when passing data down from parent to child component, you can use attributes (or exposed methods) and when passing data up from child to parent you can use events -

The way to pass data up and around in the Lightning component hierarchy is to use events

But, is there any reason why we shouldn't use bound attributes to pass data up the hierarchy? It seems to work perfectly fine - if an attribute in the child component is changed, and that attribute is bound to an attribute in the parent component, the parent component seems to change too.

3

I can say few reason:-

  1. Bound expressions provide an implementation of bidirectional data binding. Bidirectional data binding provides a convenient and powerful abstraction. However it also comes at a cost: The framework has to set up two event listeners for each bound expression, which can have a negative impact on performance when there is a large number of bound expressions. It also creates an entanglement between the model and the view that can make your code harder to maintain and issues harder to debug in non-trivial situations.
  2. Bound expressions can also create hard-to-debug errors due to the propagation of data changes through nested components.

Reference:- Lightning Components Performance Best Practices

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.