Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion docs/react-testing-library/api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,15 @@ to ensure that the props are being updated correctly (see
prefer to update the props of a rendered component in your test, this function
can be used to update props of the rendered component.

To use rerender it is necessary to use the unmount method to undo the previous rendering context.

```jsx
import {render} from '@testing-library/react'

const {rerender} = render(<NumberDisplay number={1} />)
const {rerender, unmount} = render(<NumberDisplay number={1} />)

// this will cause the rendered component to be unmounted
unmount()

// re-render the same component with different props
rerender(<NumberDisplay number={2} />)
Expand Down