mirror of
https://github.com/callstack/react-native-testing-library.git
synced 2026-09-18 23:09:04 +08:00
Improvement: Add act to update call to support hooks (#137)
### Summary Currently `render` and `fireEvent` are wrapped in `act` to support hooks. This pull request wraps the update call in `act` to support testing component updates (e.g. prop changes). ### Test plan * I have added a test for update in `__tests__/act.test.js`. * A useEffect hook should run again on `update` calls (if the hook dependency array is satisfied).
This commit is contained in:
+1
-1
@@ -384,4 +384,4 @@ expect(submitButtons).toHaveLength(3); // expect 3 elements
|
||||
|
||||
## `act`
|
||||
|
||||
Useful function to help testing components that use hooks API. By default any `render` and `fireEvent` calls are wrapped by this function, so there is no need to wrap it manually. This method is re-exported from [`react-test-renderer`](https://github.com/facebook/react/blob/master/packages/react-test-renderer/src/ReactTestRenderer.js#L567]).
|
||||
Useful function to help testing components that use hooks API. By default any `render`, `update`, and `fireEvent` calls are wrapped by this function, so there is no need to wrap it manually. This method is re-exported from [`react-test-renderer`](https://github.com/facebook/react/blob/master/packages/react-test-renderer/src/ReactTestRenderer.js#L567]).
|
||||
|
||||
Reference in New Issue
Block a user