I have cascaded components like component inside component, as per LWC documentation in order to avoid mutation the public properties (@api) of child component can't be updated.

         <c-comp2 config={config}></c-comp2>

         <c-comp3 config={config}></c-comp3>

     handleChange(event) {
         fireEvent(this.pageRef, 'searchKeyChange', 'value':event.detail.value});

@api config;
handleSearchKeyChange(searchKey) {
     this.config = searchKey

In comp3 i am performing some operations and now i want to update the config, i tried to update in the same component but it didn't work.

Created a pubSub event in comp3 and passing changed data to comp1 so that i will have updated data but no luck :(

Please let me know if anyone has faced this issue and how to handle such situation?

closed as off-topic by glls, Mohith Shrivastava, battery.cord, Jayant Das, Himanshu Apr 29 at 3:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – glls, Mohith Shrivastava, battery.cord, Jayant Das, Himanshu
If this question can be reworded to fit the rules in the help center, please edit the question.

  • you will need to provide more details as to how you are trying to send an event from cmp3 to cmp1. and please mention where youa re attempting this, communities? lex? – glls Apr 17 at 13:53

If they are parent and child components then use component.dispatchEvent(). See https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.events

There’s no need to use the reference pub-sub utility.

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