0

I have 2 sibling components inside a visualforce page. When i try to write pubsub events in the LWC components i am getting the below error

This page has an error. You might just need to refresh it. Error in $A.getCallback() [afterRender threw an error in 'c:lwcContainer' [pubsub listeners need a "@wire(CurrentPageReference) pageRef" property]] Failing descriptor: {ltng:outApp}

VF Page Code

<apex:page>
    <apex:includeLightning />

    <div id="lightningvf" />

    <script>
        $Lightning.use("c:lwcvf", function() {
          $Lightning.createComponent("c:lwcContainer",
              {},
              "lightningvf",
              function(cmp) {
                console.log("button was created");
                // do some stuff
              }
          );
        });
    </script>
</apex:page>

i have used the below blog to create 2 lightning web components https://www.santanuatonline.com/publish-subscriber-model-in-lightning-web-component/

How do i communicate between these 2 sibling LWC's which are residing inside the vf page?

0

I would maybe use the Lightning Messaging Service instead of the LWC pubsub.

See for example https://releasenotes.docs.salesforce.com/en-us/summer20/release-notes/rn_lc_message_channel.htm

| improve this answer | |

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.