RefreshEvent from the “lightning/refresh” module in Salesforce Lightning Web Component can be used to refresh the page without browser reload.
Sample Lightning Web Component code:
HTML:
<template>
<lightning-card>
<lightning-button
onclick={doRefresh}
label="Refresh"
variant="brand"
class="slds-var-m-left_x-small"
icon-name="utility:refresh"
icon-position="right"
></lightning-button>
</lightning-card>
</template>
JavaScript:
import { LightningElement } from 'lwc';
import { RefreshEvent } from "lightning/refresh";
export default class RefreshViewComponent extends LightningElement {
doRefresh() {
console.log(
'Inside doRefresh'
);
this.dispatchEvent(
new RefreshEvent()
);
}
}
js-meta.xml:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>60.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__RecordPage</target>
</targets>
</LightningComponentBundle>