profile
viewpoint

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: https://github.com/reactjs/reactjs.org/issues/new -->

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)
      setData(data)
    })
  }, [dataURL])

  return data
}

export default useData

The entire project code is here: https://github.com/justin0022/dashboard/tree/cache

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.

facebook/react

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!

useful!

Related questions

Disable react strict mode on third party libraries hot 3
Warning: Unknown DOM property for. Did you mean htmlFor? hot 2
React@16.9 block `javascript:void(0);` hot 2
TypeError: Object(...) is not a function hot 1
Warning: validateDOMNesting(...): <tr> cannot appear as a child of <table> hot 1
useEffect causes 'callback is not a function' exception hot 1
DevTools: Updating state or props in devtools does not trigger component update. 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
Keep getting `TypeError: Cannot read property 'scrollTop' of null` in a custom hook... hot 1
Route based code splitting, Loading chunk 0 failed after new deployment hot 1
map through connected component, get data of last saga call within all componenets hot 1
Github User Rank List