Ask questionsuseEffect causes 'callback is not a function' exception

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:

Uncaught TypeError: callback is not a function
    at flushFirstCallback (scheduler.development.js:348)
    at flushWork (scheduler.development.js:441)
    at (scheduler.development.js:188)

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, and even This is my component:

const RemoteControlledSliderRaw = ({ activeIndex, currentlyDragging, className, children }) => {
	const [forcedX, setForcedX] = React.useState(null);

	React.useEffect(() => {
		if (currentlyDragging) {
			window._animateItem.update = setForcedX;
		} else {
			if (window._animateItem.update) {
				window._animateItem.update = null;
	}, [currentlyDragging]);

	return (
			<SliderCore activeIndex={activeIndex} forcedX={forcedX} className={className}>

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 entire useEffect 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.


Answer questions Shrroy

Same problem: using setInterval just doesn’t work as I'd expect with react-native

const [time, setTime] = useState(0);
        useInterval(() => {
            setTime(time +1);

        return (<Text>{time}</Text>);

function useInterval(callback) {
    const savedCallback = useRef();

    // Remember the latest function.
    useEffect(() => {
        savedCallback.current = callback;
    }, [callback]);

    // Set up the interval.
    useEffect(() => {
            let id = setInterval(()=>savedCallback.current(), delay);
            return () => clearInterval(id);

I'm getting an error says "Callback() it's not a function"

enter image description here

It's working as expected in Reactjs

"dependencies": {
    "react": "16.8.3",
    "react-native": "^0.59.6",

Related questions

Disable react strict mode on third party libraries hot 7
Warning: Unknown DOM property for. Did you mean htmlFor? hot 6
TypeError: Object(...) is not a function
Refs - &#34;object is not extensible&#34;
React@16.9 block `javascript:void(0);`
Warning: validateDOMNesting(...): <tr> cannot appear as a child of <table> hot 3
"DevTools v4 is incompatible with this version of React" with React Native & latest version of React hot 3
Feedback on useEffect depndencies change error hot 3
[ESLint] Feedback for 'exhaustive-deps' lint rule hot 3
React custom hook "Should have a queue. This is likely a bug in React" error message. hot 2
DevTools: Updating state or props in devtools does not trigger component update. hot 2
Infinite loop in useEffect using blank object or array hot 2
Error on unit test : Cannot read property 'Symbol(Symbol.iterator)' of undefined hot 2
False-positive security precaution warning (`javascript:` URLs) hot 2
Hooks API - hook breaks when exported from module hot 2
Github User Rank List