You need to sign in to do that
Don't have an account?
Rohit Vaidya 3
unrelated comp@!
We have two components ComponentA and ComponentB , both are unrealated to each other, we need to update some value in component A and print that same value i component B. What are various ways of doing it.
>> In Lightning Web Components (LWC), you can use the @api decorator to create a public property in Component A and pass the updated value to Component B as a property binding. This approach requires defining a public property in Component A with the @api decorator and using the property binding syntax in Component B to retrieve the updated value
Recommend reviewing https://salesforcecodes.com/one-component-picklist-list-value-display-in-another-component-using-events-in-lightning/
>> Also, Lightning Message Service (LMS) is a communication channel provided by Salesforce to exchange messages between unrelated components. ComponentA can publish a message containing the updated value using LMS. ComponentB can subscribe to the same message channel and receive the message, extracting the value from it.
See https://trailhead.salesforce.com/content/learn/projects/communicate-between-lightning-web-components/communicate-between-unrelated-components
Related:
https://www.salesforceben.com/lightning-web-component-communication-using-events/
https://www.sfdckid.com/2020/08/api-property-lightning-web-component.html?m=1
If this information helps, please mark the answer as best. Thank you