The main concept included in this recipe is how to send an event to other components so they can refresh their contents without reloading the whole page.
<aside>
π‘ If you are not familiar with the RefreshView
API, review this section before digging into this LWC RefreshView API.
</aside>
<aside>
π Find this LWC in this folder: force-app/main/default/lwc/dispatchRefreshEvent.
</aside>
The template uses a standard lightning-record-edit-form
LDS component to allow the user to create a new account.
<aside>
β Review how a here lightning-record-edit-form
is used here:
LWC recordEditFormStaticContact and recordEditFormDynamicContact
</aside>
The handler associated to saving the account is named handleSuccess
.
In this handler, the most important and straightforward code is:
//Dispatch the refresh event
this.dispatchEvent(new RefreshEvent());
With this single line, the account standard LDS list view will receive the Refresh View signal and will refresh the data inside without requiring to reload the whole page.
If a custom LWC was in the same page, a registration for this event might be necessary to receive this event.
Did you find an issue/mistake? You donβt like something? Do you have external content that I should link to improve the learning process? Did you find it helpful? Any of those are super valuable to me. So, please write me at [email protected], and promise to answer.
<aside> βοΈ Jump to the main page: The LWC Recipes Cookbook
</aside>