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
useEffect causes 'callback is not a function' exception #15647
Comments
Same problem: using setInterval just doesn’t work as I'd expect with react-native
I'm getting an error says It's working as expected in Reactjs https://codesandbox.io/s/z69z66kjyx
|
I've seen this happen because of wrong If you see this, try adding |
I have fixed the problem by using |
That’s not a real fix and will likely blow up later. I recommend to fix the underlying problem instead. |
Try adding |
Thank you @gaearon, the bug has been fixed, I just did |
@gaearon Adding that dep didn't fix the issue for me. It seems to crop up when performing an async task in const EnvironmentSelectorScreen = function() {
const [envs, setEnvs] = useState(null);
useEffect(() => {
const load = async function() {
const res = await getAllEnvs();
setEnvs(res);
};
load();
}, []);
if (!envs) {
return (<Loading />);
}
return (
<View style={style.container}>
<FlatList
data={envs}
renderItem={({ item }) => <Env item={item} />}
/>
</View>
);
}; I can try to make an example repo later today that reproduces the issue. |
Not work for me with react-konva. |
I'm having the same error here with I'm using I followed what @gaearon recommended, downgraded scheduler to 0.13.6 and it worked. |
Walking around that issue I finded solution:
|
It seems that we have a dep to an old version of scheduler that doesn't work very well with React Hook see this issue: facebook/react#15647
It seems that we have a dep to an old version of scheduler that doesn't work very well with React Hook see this issue: facebook/react#15647
It could be a syntactic error. Like you I am performing an async task is useEffect. This stack overflow post solved my issue which oddly enough was a missing semi-colon https://stackoverflow.com/questions/42036349/uncaught-typeerror-intermediate-value-is-not-a-function |
i am having this issue, i am using yarn and installed sheduler version 0.20.2 but the error still persist |
I am having the same issue. I am using npm to install all my packages and everything worked fine, until I included useEffect. import { useState, useEffect, useCallback } from "react" This is how I have imported useEffect from react. BTW, I am using Next.js here. const getAllData = useCallback( async() => {
await axios.post('http://localhost:5080/api/table', data)
.then((response) => {
setTable(response.data)
})
})
useEffect=(() => {
getAllData();
},[getAllData]) Here is how I have used in useEffect and useCallback in my functions. I am trying to map data that is stored in the table useState <tbody>
{
table?.map(({_id,name,email,contact,hobby})=>(
<tr key={_id}>
<td>{_id}</td>
<td>{name}</td>
<td>{email}</td>
<td>{contact}</td>
<td>{hobby}</td>
</tr>
))
}
</tbody> The script actually worked fine when I had not used useEffect and was just calling the function through a button. |
+1 |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
useEffect
results in the following exception in the console:I am unable to isolate the problem enough to create a sandbox that reproduces it. I am posting it here in case there is still some value in it (it seems slightly related to react-navigation/react-navigation#5851, gaearon/overreacted.io#460 and even #15194).
This is my component:
What might be interesting is that I set a global object to point to a
setState
setter. That can be called from the outside. I am not sure exactly how the exception occurs, but if I comment out the entireuseEffect
bit, it goes away.What is the expected behavior?
No exception. Or at least one that provides some explanation as to what is wrong.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
16.8.6. I don't know if this worked with earlier versions.
The text was updated successfully, but these errors were encountered: