anon_guest
anon_guest

Reputation: 33

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.

Upvotes: 3

Views: 657

Answers (1)

mss
mss

Reputation: 1493

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

enter image description here

Upvotes: 2

Related Questions