You need to sign in to do that
Don't have an account?
Communicate with LWC outside of hierarchy
Hi there,
I know it is possible to call a function on a child LWC by anotating the function with @api and using a querySelector to find the child BUT is it possible to do similar for a LWC which is not nested and not in the hierarchy?
I know it is possible to call a function on a child LWC by anotating the function with @api and using a querySelector to find the child BUT is it possible to do similar for a LWC which is not nested and not in the hierarchy?
To communicate down the containment hierarchy, owner and parent components can call JavaScript methods on child components.
I recommend reviewing this post where a similar discussion is made
Let me know if this helps, if it does, please close the query by marking this answer as best. It may help others in the community. Thank You!
All Answers
To communicate down the containment hierarchy, owner and parent components can call JavaScript methods on child components.
I recommend reviewing this post where a similar discussion is made
Let me know if this helps, if it does, please close the query by marking this answer as best. It may help others in the community. Thank You!
It is not possible to communicate with LWC outside of the hierarchy. The recommended approach would be to use Lightning Message Service(https://developer.salesforce.com/docs/component-library/bundle/lightning-message-service/documentation) in such a decoupled scenario.
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you