kentcdodds / testing-react-apps

A workshop for testing react applications
https://www.epicreact.dev/modules/testing-react-apps-v1/testing-react-apps-welcome
Other
1.07k stars 719 forks source link

Cannot render Counter with createRoot #89

Closed christianJessMark closed 2 years ago

christianJessMark commented 2 years ago

Using the new createRoot syntax I cannot see the Counter component (or anything else I try to render).

My code:

  act(() => {
    const div = document.createElement('div')
    document.body.append(div)
    createRoot(div).render(<Counter />)
  })

Output of console.log(document.body.innerHtml) is <div><div>

christianJessMark commented 2 years ago

Doh. Looked at the final version, only the render needs to be wrapped in act.