Ask questionsReact custom hook "Should have a queue. This is likely a bug in React" error message.

<!-- Note: if the issue is about documentation or the website, please file it at: -->

Do you want to request a feature or report a bug? Bug

What is the current behavior? Getting this error message: Should have a queue. This is likely a bug in React. Please file an issue.

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.

I tried to implement a simple data cache in a custom hook:

import { useState, useEffect } from 'react'

const get = url => {
  return fetch(url)
    .then(res => res.text())
    .then(data => JSON.parse(data))

const cache = new Map()

const useData = dataURL => {
  const [data, setData] = useState(null)
  if (cache.has(dataURL)) {
    return cache.get(dataURL)

  useEffect(() => {
    get(dataURL).then(data => {
      cache.set(dataURL, data)
  }, [dataURL])

  return data

export default useData

The entire project code is here:

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? Using React 16.8.2, Chrome, and MacOS.


Answer questions threepointone

I'm curious why you didn't see the other error messages in your app (specifically about the change in order). Closing this for now, but we may revisit if this happens again in the future, or if you have any new information to share. Thanks!


Related questions

Disable react strict mode on third party libraries hot 4
Refs - &#34;object is not extensible&#34; hot 4
Warning: Unknown DOM property for. Did you mean htmlFor? hot 4
Warning: validateDOMNesting(...): <tr> cannot appear as a child of <table> hot 3
React@16.9 block `javascript:void(0);` hot 3
DevTools: Updating state or props in devtools does not trigger component update. hot 2
Hooks API - hook breaks when exported from module hot 2
Feedback on useEffect depndencies change error hot 2
TypeError: Object(...) is not a function hot 1
useEffect causes 'callback is not a function' exception hot 1
Invariant Violation: Invalid hook call. Hooks can only be called inside of the body of a function component hot 1
eslint-plugin-react-hooks v2.0.0 is not loaded correctly. hot 1
Old references retained by memoizedProps in fiber hot 1
Stale values for useState inside callback functions hot 1
ReactDomServer - renderToString Failing with Context Provider on IE11 hot 1
Github User Rank List