MCPcopy
hub / github.com/testing-library/react-testing-library / renderRoot

Function renderRoot

src/pure.js:155–226  ·  view source on GitHub ↗
(
  ui,
  {
    baseElement,
    container,
    hydrate,
    queries,
    root,
    wrapper: WrapperComponent,
    reactStrictMode,
  },
)

Source from the content-addressed store, hash-verified

153}
154
155function renderRoot(
156 ui,
157 {
158 baseElement,
159 container,
160 hydrate,
161 queries,
162 root,
163 wrapper: WrapperComponent,
164 reactStrictMode,
165 },
166) {
167 act(() => {
168 if (hydrate) {
169 root.hydrate(
170 strictModeIfNeeded(
171 wrapUiIfNeeded(ui, WrapperComponent),
172 reactStrictMode,
173 ),
174 container,
175 )
176 } else {
177 root.render(
178 strictModeIfNeeded(
179 wrapUiIfNeeded(ui, WrapperComponent),
180 reactStrictMode,
181 ),
182 container,
183 )
184 }
185 })
186
187 return {
188 container,
189 baseElement,
190 debug: (el = baseElement, maxLength, options) =>
191 Array.isArray(el)
192 ? // eslint-disable-next-line no-console
193 el.forEach(e => console.log(prettyDOM(e, maxLength, options)))
194 : // eslint-disable-next-line no-console,
195 console.log(prettyDOM(el, maxLength, options)),
196 unmount: () => {
197 act(() => {
198 root.unmount()
199 })
200 },
201 rerender: rerenderUi => {
202 renderRoot(rerenderUi, {
203 container,
204 baseElement,
205 root,
206 wrapper: WrapperComponent,
207 reactStrictMode,
208 })
209 // Intentionally do not return anything to avoid unnecessarily complicating the API.
210 // folks can use all the same utilities we return in the first place that are bound to the container
211 },
212 asFragment: () => {

Callers 1

renderFunction · 0.85

Calls 3

strictModeIfNeededFunction · 0.85
wrapUiIfNeededFunction · 0.85
renderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…