Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call function from another React file

I have a function in a .react.js file that works fine in that file that imports as undefined in a different file.

So in in file1.react.js:

const functionName= function (): React.Node {
  return (
    <// insret code here>
  );
};

export default functionName;

and in file2.react.js:

import {functionName} from 'file1.react'

But when I try to call {functionName()} it says functionName isn't a function and when I do {typeof functionName} it says it's undefined.

FYI: I referenced question 43262599 and 54199264 when trying to get this to work.

like image 951
anon_guest Avatar asked Sep 04 '26 20:09

anon_guest


1 Answers

I guess this pictures is self-explanatory and will help you to know where you are going wrong

enter image description here

like image 145
mss Avatar answered Sep 07 '26 10:09

mss



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!