📌  相关文章
📜  typeerror: func.apply is not a function - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:23.483000             🧑  作者: Mango

代码示例2
A personal note - Opinionated based on my experience -- may not be applicable in your cases. 

TLDR : Other seemingly unrelated errors that you are ignoring for the time being might be causing this error 
        Get rid of all those errors and your error might just take care of itself too.


Take a closer look at the (seemingly unrelated ) errors that the console is throwing your way. 
Unrelated errors might be responsible. 

For ex. I received TypeError: func.apply is not a function ----- this suggests that something we've passed to JS / React is not a function. 

In my case, I had passed a "" to an onClick listener as a placeholder ie. onClick = { "" }. In my experience, as it was not 
clicked by the user, this would not throw a catastrophic response. ie. the error in the console would be red but the react app would 
still work ie. render in a seemingly fine way. But a error lurks and it may come back to haunt you

div
 |----
     xyz
      |----button

This was the basic component structure in my app, I had (wrongly) passed onClick = { "" } to the parent div. This did not immediately create an issue during runtime ( I did throw an error but did not break anything ). However, 
when I clicked on button, the event bubbled up , upto the div and thats when the " TypeError: func.apply is not a function " error was thrown. This broke the React App.