I’m trying to reuse the functions we wrote in the masterPage.js by the export
and import
keywords but they don’t work. My code is as follow:
// masterPage.js
...
export function foo(value) {
return value + 1;
}
...
// someOtherPage.js
import { foo } from 'masterPage';
...
$w.onReady(() => {
let bar = 1;
bar = foo(bar);
});
...
The console told me that it couldn’t find masterPage
. I’ve tried these variances: master-page, wix-master-page, WixMasterPage, wixMasterPage. I’ve tried removing the {} around foo as well. None of them worked.
Is there anyway to do this and/or best practices to reuse code?
Thank you in advance! <3