Last updated on December 28, 2022
Sometimes while exporting components and functions in react you might face an error “Object is not a function”. The clear meaning to this error is that something in your code that you are trying to use as a function is an object. When you face this error the first thing to do is look at the line where this error occurred.
Once you know which line it is look at from where you are importing the function that you are trying to call. Now in the file check if there is any default export. If there is no default export than you should look if there is any export. If there is no default export but there are exports just close the variable in curly braces while importing. Here is an example
import {funcName} from "./funcfile"
If there is default export then import it normally like this
import funcName from "./funcfile"
Comment below if you have any doubt or your question is different. I usually reply within 24hrs.
Be First to Comment