Reputation: 125
I want to create a global function.
For example, create a Javascript
file with
function increment (val) {
return val + 1;
}
And I want to use this function in app.js
or some other component.
How do I set up this structure in ReactJS
?
Upvotes: 1
Views: 111
Reputation: 2225
Just export
your function as a module and import
it in app.js
export function increment (val) {
return val + 1;
}
Then in your app.js
:
import { increment } from 'your_module_path';
//...
let b = increment(1);
Upvotes: 1