import { act } from 'react'; import { createRoot } from 'react-dom/client'; export function renderHook(useHook: () => T) { let currentValue: T; function TestComponent() { currentValue = useHook(); return null; } const container = document.createElement('div'); const root = createRoot(container); act(() => { root.render(); }); return { result: { get current() { return currentValue; }, }, rerender() { act(() => { root.render(); }); }, unmount() { act(() => { root.unmount(); }); }, }; }