Skip to content

Commit 44335b5

Browse files
snaumovKent C. Dodds
authored and
Kent C. Dodds
committed
docs: update Readme.md (#163)
Update example of fireEvent usage, complying with new 5.0.0 version.
1 parent fff012a commit 44335b5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,17 +519,16 @@ If you want to trigger the
519519
[`onChange`](https://reactjs.org/docs/dom-elements.html#onchange) handler of a
520520
[controlled component](https://reactjs.org/docs/forms.html#controlled-components)
521521
with a different `event.target.value`, sending `value` through `eventProperties`
522-
won't work like it does with `Simulate`. You need to change the element's
523-
`value` property, then use `fireEvent` to fire a `change` DOM event.
522+
won't work like it does with `Simulate`. You need to use `fireEvent` to fire a
523+
`change` DOM event with `value` property set on `target`
524524
525525
```javascript
526526
import {render, fireEvent} from 'react-testing-library'
527527

528528
const {getByLabelText} = render(<Form />)
529529

530530
const comment = getByLabelText('Comment')
531-
comment.value = 'Great advice, I love your posts!'
532-
fireEvent.change(comment)
531+
fireEvent.change(comment, { target: { value: 'Great advice, I love your posts!' })
533532
```
534533
535534
### `waitForElement`

0 commit comments

Comments
 (0)