-
Notifications
You must be signed in to change notification settings - Fork 45.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: func.apply is not a function / Uncaught TypeError: destroy is not a function #14838
Comments
This is the real error, and indicates that you're returning a value from
@gorilla-devs can you confirm that you received that warning? Looking at the code that you shared you're using
async function fetchComment(commentId) {
// You can await here
}
useEffect(() => {
fetchComment(commentId);
}, [commentId]); |
How can I do something like this though?
|
see the answer from @aweary:
Or you could wrap it in an IIFE or ... some solutions at stackoverflow |
If you try to do this you’ll see a warning in the console that tells you exactly how to do that correctly — including a code example. Have you read it? |
The warnings are super nice! Love it! @gaearon |
I had a similar problem that this thread helped me resolve: Which I had to replace for |
Thanx! I will never more use useEffect with async =) |
We had a the error exactly like @Gsiete did, thanks for the comment. |
I've fixed this issue by moving code inside a function and calling it inside const [versionName, setVersionName] = useState(`${version.name} copy`)
const [validationsErrors, setValidationsErrors] = useState('')
useEffect(() => {
const runValidation = () => {
const errors = validation({ versionName })
if (size(errors) > 0) {
setValidationsErrors(errors)
return null
} else {
setValidationsErrors(null)
}
}
runValidation()
}, [versionName]) |
its happened with my
to
|
@MoeMamdouh Thanks! |
For calling async inside useEffect you can use IEFE functionuseEffect(() => {
(async () => {
await asyncCall()
})()
}, [])
|
I got both cus I forgot wrapper an async function with {} in useEffect:
fix:
|
Its very silly bug |
Do you want to request a feature or report a bug?
A bug
What is the current behavior?
Doing certain dispatches with redux or other random things cause react to crash. It's working perfectly on react 16.8.0-alpha0 but as soon as I update to alpha 1 it crashes.
The problem looks like is caused here (?):
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
Well, I don't really know how to reproduce but you can find my app code here, here are the important files:
configureStore.dev.js -> Has all configs of redux
this and this are just random places where it happens.
Here are some more logs that might be useful:
I tried giving you every piece of information I could, if you need any more info I'll be more than happy to help
What is the expected behavior?
Well, it shouldn't crash I guess
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
It's working perfectly on react 16.8.0-alpha 0 but as soon as I update to alpha 1 or later it crashes.
The text was updated successfully, but these errors were encountered: