function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Alexander Zaytsev 1Alexander Zaytsev 1 

Force refreshView in LWC

In Aura, we can do
$A.get('e.force:refreshView').fire();
to cause standard components to update.

How can we do an equivalent in LWC because sfdx refuses to publish .js code with $A in it saying the usage is disallowed in LWC?

For now i tricked it with 
eval("$A.get('e.force:refreshView').fire();");
but that is obviously less than ideal....
Raj VakatiRaj Vakati
If its an apex wire adaptor we can do it using the refreshApex .. but if you want to refresh other standard components  i am not able to find any think in documents 

you can use window.realod() ... 
 
Alexander Zaytsev 1Alexander Zaytsev 1
window.reload()


is like using a microscope as a hammer.

The force:refreshView is actually implemented by components individually and doesn't cause the full window reload. 

Anil K 85Anil K 85
// import
import { updateRecord } from 'lightning/uiRecordApi';

// a way (WORKAROUND) to refresh data in standard components
updateRecord({ fields: { Id: this.recordId } });
Samuel MSamuel M
Hi Alexander, 
Please follow the below link,
https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.apex
Thanks!
Kindly mark this as best answer so that it will also help others to find the solution
Ramakrishna Reddy GouniRamakrishna Reddy Gouni
Please follow below link
https://rkreddy-sfdx.blogspot.com/2019/12/how-to-refresh-lightning-web-component.html
If it is useful for you, then please select as best answer.


thanks 
Ramakrishna Reddy 
Alejandra ZapataAlejandra Zapata
window.location.reload();
Pratibha Sundaramoorthy 8Pratibha Sundaramoorthy 8
I have tested it. window.location.reload() works! Thank you Alejandra Zapata.