0

Just trying to load a js library in a LWC. Cannot even get the thing to load. I just want it to load and do nothing.

Static resource here:

Name headerConfig
Namespace Prefix    
Description 
MIME Type   text/javascript
Cache Control   Private
Size    615 bytes
import { LightningElement } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { loadScript, loadStyle } from 'lightning/platformResourceLoader';
import headerConfig from '@salesforce/resourceUrl/headerConfig';


export default class UtahHeader extends LightningElement {

error;
successMessage = '';
utahHeaderInit = false;

renderedCallback() {
    
    // if(this.utahHeaderInit) {
    //     return;
    // }

    // this.utahHeaderInit = true;
    Promise.all([
    loadScript(this, headerConfig)
    ])
    
    .then(() => {
        this.error = undefined;
        this.showSuccessMessage();
        alert('loaded');
        // this.loadConfig();
        // this.loadMainMenu();
    })
    .catch(error => {
        this.error = error;
        this.dispatchEvent(
            new ShowToastEvent({
                title: 'Errrorrr',
                variant: 'error',
            }),
        );
    });
}

showSuccessMessage() {
    this.successMessage = 'loaded succ';
    alert('scripts loaded succ');
}
    <template>
    <lightning-card title="Third Party Library Demo" icon-name="custom:custom19">
        <p><b style="color:blue;">{successMessage}</b></p>
    </lightning-card>
</template>

Any ideas what I'm doing wrong here? Tried to follow other posts but I'm able to rectify mine.. if I try to add error.message, it says it's an undefined property so I can't even find out what the issue is.
0

Nvm, seems like a problem with the external library itself. React loads fine.

1
  • Do you have a link to the 3rd party library (so I can download and try it)?
    – arut
    Aug 15 '20 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.