I have a react component where I'm importing a function from another file like this:
import documentIcons from '/documentIcons';
Then I'm trying to use that function like this:
let file = this.state.selectedFile; //this returns fine
let fileExt = file.name.split('.').pop(); //this also works
let fileIcon = documentIcons(fileExt); //this throws the error
But I keep getting this error:
Uncaught TypeError: Object(...) is not a function
The documentIcons.js file looks like this:
const icons= {
"jlr": "/icn/typeA.png",
"trr": "/icn/typeB.png",
"bpx": "/icn/typeC.png",
};
export const documentIcons = (f) => {
this.icons.find(f)
}
I'm passing in a file extension(jlr, trr, or bpx) and I want the path to that icon returned.
Is there a way to do this in react/es6?
Thanks!
export defaultinstead ofexport