feat: add rerender as an alias for update (#149)

<!-- Please provide enough information so that others can review your pull request. -->
<!-- Keep pull requests small and focused on a single change. -->

### Summary

Users of `react-testing-library` use `rerender` wording instead of `update`. Let's make it easier for them by aliasing it.
See: https://testing-library.com/docs/react-testing-library/api#rerender

### Test plan

Added cases for JS tests and TS typings
This commit is contained in:
Michał Pierzchała
2019-04-14 10:09:46 +02:00
committed by Kacper Wiszczuk
parent 488a2ca5cc
commit 439db6c823
5 changed files with 9 additions and 3 deletions
+3 -1
View File
@@ -5,7 +5,7 @@ title: API
This page gathers public API of `react-native-testing-library` along with usage examples.
## `render`
## `render`
- [`Example code`](https://github.com/callstack/react-native-testing-library/blob/master/src/__tests__/render.test.js)
@@ -98,6 +98,8 @@ A method returning an array of `ReactTestInstance`s with matching a React compon
### `update: (element: React.Element<any>) => void`
_Also available under `rerender` alias_
Re-render the in-memory tree with a new root element. This simulates a React update at the root. If the new element has the same type and key as the previous element, the tree will be updated; otherwise, it will re-mount a new tree. This is useful when testing for `componentDidUpdate` behavior, by passing updated props to the component.
[Example code](https://github.com/callstack/react-native-testing-library/blob/f96d782d26dd4815dbfd01de6ef7a647efd1f693/src/__tests__/act.test.js#L31-L37)