Last active
May 21, 2021 18:15
-
-
Save madmax983/a86100420e77dc837635bbbebe824828 to your computer and use it in GitHub Desktop.
LWC Debugging Tips and Tricks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
{lwcPrettyProperty} | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement } from 'lwc'; | |
export default class PrettyPrintProperty extends LightningElement { | |
property; | |
get lwcPrettyProperty() { | |
return JSON.stringify(this.property, null, 4); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
{prettyContacts} | |
<button onclick={handleRefresh}>Refresh</button> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement } from 'lwc'; | |
import { refreshApex } from '@salesforce/apex'; | |
import getContacts | |
from "@salesforce/apex/ContactController.getContacts"; | |
export default class TestCacheableApexOnDemand extends LightningElement { | |
@wire(getcontacts) | |
contacts; | |
handleRefresh() { | |
refreshApex(this.contacts); | |
} | |
get prettyContacts() { | |
return JSON.stringify(this.contacts, null, 4); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The pretty print of wires properties also works great for generating your mock json files for testing!