@samitouri / QOS-React / commits / 38e3b23483

Tweak error message for "Should have a queue" (#29626)

Sophie Alpert committed May 29, 2024 at 08:41 UTC 38e3b23483bf7a612391cd617a8926aa1f3cf52e
2 files changed +5 -3
packages/react-reconciler/src/ReactFiberHooks.js
+4 -2
@@ -1260,7 +1260,8 @@ function updateReducerImpl<S, A>(
1260
1261 if (queue === null) {
1262 throw new Error(
1263 - 'Should have a queue. This is likely a bug in React. Please file an issue.',
1263 + 'Should have a queue. You are likely calling Hooks conditionally, ' +
1264 + 'which is not allowed. (https://react.dev/link/invalid-hook-call)',
1265 );
1266 }
1267
@@ -1506,7 +1507,8 @@ function rerenderReducer<S, I, A>(
1507
1508 if (queue === null) {
1509 throw new Error(
1509 - 'Should have a queue. This is likely a bug in React. Please file an issue.',
1510 + 'Should have a queue. You are likely calling Hooks conditionally, ' +
1511 + 'which is not allowed. (https://react.dev/link/invalid-hook-call)',
1512 );
1513 }
1514
scripts/error-codes/codes.json
+1 -1
@@ -305,7 +305,7 @@
305 "308": "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().",
306 "309": "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://react.dev/link/strict-mode-string-ref",
307 "310": "Rendered more hooks than during the previous render.",
308 - "311": "Should have a queue. This is likely a bug in React. Please file an issue.",
308 + "311": "Should have a queue. You are likely calling Hooks conditionally, which is not allowed. (https://react.dev/link/invalid-hook-call)",
309 "312": "Rendered more hooks than during the previous render",
310 "313": "Unknown priority level. This error is likely caused by a bug in React. Please file an issue.",
311 "314": "Pinged unknown suspense boundary type. This is probably a bug in React.",