5

This is related to this question: Navigation in Desktop Lightning Experience not Destroying Components

My components are listening to the force:refreshView event, but since the components are cached after navigation according to the question I linked, they still fire even when they are no longer on the page. This causes errors to show up.

I can't destroy them because then they do not reappear when using the back button to go to the previous page that used to contain my components.

Is there a way that I can detect if my components are currently being displayed on the page that fired the force:refreshView event?

UPDATE: As an intermediate solution, I'm checking window.location.path to see if it contains the name of the SObjectType these components can appear on before executing any other logic.

var path = window.location.pathname;
var isOpportunityPage = path.includes('/Opportunity');

if(isOpportunityPage){
    // Do stuff here
}

This doesn't feel right at all, but it's something at least.

0

You must log in to answer this question.

Browse other questions tagged .