Closed
Description
React version: 18.2.0
Next version: 13.1.1
Steps To Reproduce
- Suspend using a (fake) promise in a client component in app dir (next)
- Try to useState after the use() call
'use client';
import { use, useState } from 'react';
const testPromise = new Promise((resolve) => {
setTimeout(() => {
resolve('use test promise');
});
});
export default function Page() {
use(testPromise);
useState(0);
return <h1>Test</h1>;
}
Link to code example:
https://codesandbox.io/s/github/xiel/app-playground/tree/suspense-error/?from-embed=&file=/app/page.tsx
The current behavior
Suspending for a promise in a client component and using state/reducer after results in errors during hydration:
react-dom.development.js?9d87:94 Warning: An error occurred during hydration. The server HTML was replaced with client
react-dom.development.js?9d87:94 Warning: You are accessing "digest" from the errorInfo object passed to onRecoverableError.
on-recoverable-error.js?eb92:17 Uncaught Error: Should have a queue. This is likely a bug in React. Please file an issue.
The expected behavior
No error during hydration.