Skip to main content

Hello,

 

I am able to redirect from a lightning component to another lightning component using:

<c:SecondLighningComp recordId="{!v.recordId}" />

 

But I cannot redirect to second lightning component on click of a button.

<lightning:button label="Click me" variant="brand" onclick="{!c.handleYes}"></lightning:button>

function:

handleYes: function(component, event, helper) {

var urlEvent = $A.get("e.force:navigateToComponent");

urlEvent.params({

componentDef: "c:SecondLighningComp",

componentAttributes: {}

});

urlEvent.fire();

}

 

The second component calls an apex class that uses ApexPages.currentPage().getParameters().get.(Multiple record values) which is returning null. I cannot change anything in the apex class.

 

How to approach this?

#Salesforce Developer

1 respuesta
  1. 29 oct 2021, 02:00

    Hi  shylesh,

     

    Starting in API version 43.0, the force:navigateToComponent event is deprecated. For more information, see Components with Minimum API Version Requirements. We recommend implementing the lightning:isUrlAddressable interface on your target component and navigating to the component using lightning:navigation component with the standard__component page type instead. This generates a route in the format /cmp/{componentName}?myAttr=attrValue.

     

    https://developer.salesforce.com/docs/component-library/bundle/force:navigateToComponent/documentation

     

    Migrate to lightning:isUrlAddressable from force:navigateToComponent

    https://developer.salesforce.com/docs/atlas.en-us.234.0.lightning.meta/lightning/components_navigation_migrate_to_isUrlAddressable.htm

0/9000