(
container,
{
hydrate,
onCaughtError,
onRecoverableError,
ui,
wrapper: WrapperComponent,
reactStrictMode,
},
)
| 90 | } |
| 91 | |
| 92 | function createConcurrentRoot( |
| 93 | container, |
| 94 | { |
| 95 | hydrate, |
| 96 | onCaughtError, |
| 97 | onRecoverableError, |
| 98 | ui, |
| 99 | wrapper: WrapperComponent, |
| 100 | reactStrictMode, |
| 101 | }, |
| 102 | ) { |
| 103 | let root |
| 104 | if (hydrate) { |
| 105 | act(() => { |
| 106 | root = ReactDOMClient.hydrateRoot( |
| 107 | container, |
| 108 | strictModeIfNeeded( |
| 109 | wrapUiIfNeeded(ui, WrapperComponent), |
| 110 | reactStrictMode, |
| 111 | ), |
| 112 | {onCaughtError, onRecoverableError}, |
| 113 | ) |
| 114 | }) |
| 115 | } else { |
| 116 | root = ReactDOMClient.createRoot(container, { |
| 117 | onCaughtError, |
| 118 | onRecoverableError, |
| 119 | }) |
| 120 | } |
| 121 | |
| 122 | return { |
| 123 | hydrate() { |
| 124 | /* istanbul ignore if */ |
| 125 | if (!hydrate) { |
| 126 | throw new Error( |
| 127 | 'Attempted to hydrate a non-hydrateable root. This is a bug in `@testing-library/react`.', |
| 128 | ) |
| 129 | } |
| 130 | // Nothing to do since hydration happens when creating the root object. |
| 131 | }, |
| 132 | render(element) { |
| 133 | root.render(element) |
| 134 | }, |
| 135 | unmount() { |
| 136 | root.unmount() |
| 137 | }, |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | function createLegacyRoot(container) { |
| 142 | return { |
nothing calls this directly
no test coverage detected
searching dependent graphs…