Skip to main content
edited body
Source Link
Ronnie
  • 2.1k
  • 1
  • 11
  • 13

you need to make this call from the connectedCallback() method. doing so will have resolved your import by this time. See below:

import { myFunctionmyfunction } from 'c/reusableLWCFunctions';

export default class myLWC extends NavigationMixin(LightningElement){

    connectedCallback(){
      myFunctionmyfunction('THIS WAS CALLED FROM IMPORTED FUNCTION');
    }

}

the constructor for your case would really be useless. in fact in most cases I don't even see the need in using it. connectedCallback is where you want to make any calls to your imports.

you need to make this call from the connectedCallback() method. doing so will have resolved your import by this time. See below:

import { myFunction } from 'c/reusableLWCFunctions';

export default class myLWC extends NavigationMixin(LightningElement){

    connectedCallback(){
      myFunction('THIS WAS CALLED FROM IMPORTED FUNCTION');
    }

}

the constructor for your case would really be useless. in fact in most cases I don't even see the need in using it. connectedCallback is where you want to make any calls to your imports.

you need to make this call from the connectedCallback() method. doing so will have resolved your import by this time. See below:

import { myfunction } from 'c/reusableLWCFunctions';

export default class myLWC extends NavigationMixin(LightningElement){

    connectedCallback(){
      myfunction('THIS WAS CALLED FROM IMPORTED FUNCTION');
    }

}

the constructor for your case would really be useless. in fact in most cases I don't even see the need in using it. connectedCallback is where you want to make any calls to your imports.

Source Link
Ronnie
  • 2.1k
  • 1
  • 11
  • 13

you need to make this call from the connectedCallback() method. doing so will have resolved your import by this time. See below:

import { myFunction } from 'c/reusableLWCFunctions';

export default class myLWC extends NavigationMixin(LightningElement){

    connectedCallback(){
      myFunction('THIS WAS CALLED FROM IMPORTED FUNCTION');
    }

}

the constructor for your case would really be useless. in fact in most cases I don't even see the need in using it. connectedCallback is where you want to make any calls to your imports.