I have this function in a javascript-file:
//utils/commons.js
export function funcName() {
return 1;
}
In a component I refer to it this way:
import React from 'react';
const funcName = import('../../utils/commons');
const MyComponent = () => {
let res = funcName();
console.log('res:',res);
return(
<>
<div>
hello
</div>
)};
export default MyComponent;
This seems to be the right way when googling this matter. However, in the console I see:
Uncaught TypeError: funcName is not a function
If I would write a console.log inside the common.js-file (somewhere outside the function) then it is printed. So the file is getting included. But the function is not recognized for some reason.