function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vishwas B NVishwas 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.User-added image

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';
 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Vishwas,

>> 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.