You need to sign in to do that
Don't have an account?
Vishwas B N
How to refer JS from one Component in another
Hi Team,
i have 2 LWC component as attached image. I have a function in operationActionExtended.js withing operationActionComponent to be reused in the newDiscrepancyComponent.js.
So how can i import the function from the component.
Below is the import statement i am using, which is not working
import {getmodifiedbuildstationlist} from 'c/operationActionsComponent/operationActionsExtended';
i have 2 LWC component as attached image. I have a function in operationActionExtended.js withing operationActionComponent to be reused in the newDiscrepancyComponent.js.
So how can i import the function from the component.
Below is the import statement i am using, which is not working
import {getmodifiedbuildstationlist} from 'c/operationActionsComponent/operationActionsExtended';
>> https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.js_share_code
As mentioned in the above link can you try creating an ES6 module is a JavaScript file that explicitly exports variables or functions that other modules can use. Modules make it easier to structure your code without polluting the global scope.
Let me know if it helps you and close your query by marking it as the best answer so that it can help others in the future.
Thanks.