mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-22 20:01:57 +00:00
docs(act.md): correct ReactDOM to ReactDOMClient (#7156)
* docs(act.md): correct ReactDOMClient to ReactDOM * docs(act.md): switch the import to ReactDOMClient instead
This commit is contained in:
@@ -90,7 +90,7 @@ To test the render output of a component, wrap the render inside `act()`:
|
||||
|
||||
```js {10,12}
|
||||
import {act} from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import ReactDOMClient from 'react-dom/client';
|
||||
import Counter from './Counter';
|
||||
|
||||
it('can render and update a counter', async () => {
|
||||
@@ -99,7 +99,7 @@ it('can render and update a counter', async () => {
|
||||
|
||||
// ✅ Render the component inside act().
|
||||
await act(() => {
|
||||
ReactDOM.createRoot(container).render(<Counter />);
|
||||
ReactDOMClient.createRoot(container).render(<Counter />);
|
||||
});
|
||||
|
||||
const button = container.querySelector('button');
|
||||
@@ -119,7 +119,7 @@ To test events, wrap the event dispatch inside `act()`:
|
||||
|
||||
```js {14,16}
|
||||
import {act} from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import ReactDOMClient from 'react-dom/client';
|
||||
import Counter from './Counter';
|
||||
|
||||
it.only('can render and update a counter', async () => {
|
||||
@@ -174,4 +174,4 @@ global.IS_REACT_ACT_ENVIRONMENT=true
|
||||
|
||||
In testing frameworks like [React Testing Library](https://testing-library.com/docs/react-testing-library/intro), `IS_REACT_ACT_ENVIRONMENT` is already set for you.
|
||||
|
||||
</Note>
|
||||
</Note>
|
||||
|
||||
Reference in New Issue
Block a user