Testing, debugging, and internal APIs.
Batches updates for testing.
function act(callback: () => void | Promise<void>): Promise<void>;import { act } from 'react';
import { createRoot } from 'react-dom/client';
test('updates state', async () => {
const root = createRoot(document.createElement('div'));
await act(async () => root.render(<Counter />));
await act(async () => button.click());
expect(container.textContent).toBe('Count: 1');
});Debug stack traces (dev only).
function captureOwnerStack(): string | null;if (process.env.NODE_ENV === 'development') {
const stack = captureOwnerStack();
console.log('Rendered from:', stack);
}React version string.
const version: string;console.log('React version:', version); // "19.2.0"__COMPILER_RUNTIME - Used by React Compiler__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE - React internal stateWarning: These are internal only and should not be used in application code.