Skip to content

Instantly share code, notes, and snippets.

@TheShubhamVsnv
Created May 14, 2023 15:28
Show Gist options
  • Save TheShubhamVsnv/5bb7f99f94bb06df82dce8c78f532105 to your computer and use it in GitHub Desktop.
Save TheShubhamVsnv/5bb7f99f94bb06df82dce8c78f532105 to your computer and use it in GitHub Desktop.
spinner.js
import { LightningElement, track } from 'lwc';
export default class MyComponent extends LightningElement {
// Boolean variable to track if the spinner should be shown or not
@track isLoading = false;
// Method triggered when the button is clicked
handleButtonClick() {
// Set isLoading to true to display the spinner
this.isLoading = true;
// Simulating a delay before hiding the spinner
setTimeout(() => {
// Set isLoading back to false to hide the spinner
this.isLoading = false;
}, 2000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment