Skip to content

Commit 859e29c

Browse files
jmporchetthymikee
authored andcommitted
docs: provide example for componentDidMount (#144)
### Summary Some people find it useful to search for specific terms when browsing the docs. Specifying the concrete utility of the `update` method makes the doc more useful :)
1 parent b4cfb95 commit 859e29c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/API.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ A method returning an array of `ReactTestInstance`s with matching a React compon
9898
9999
### `update: (element: React.Element<any>) => void`
100100

101-
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.
101+
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.
102+
103+
[Example code](https://github.com/callstack/react-native-testing-library/blob/f96d782d26dd4815dbfd01de6ef7a647efd1f693/src/__tests__/act.test.js#L31-L37)
102104

103105
### `unmount: () => void`
104106

0 commit comments

Comments
 (0)