Skip to content

Commit

Permalink
docs: Document known issue with React 16.8
Browse files Browse the repository at this point in the history
These warnings will be common among users with React 16.8. By adding
this to the README we can address a common concern until React 16.9
becomes common.
  • Loading branch information
JSFernandes committed Aug 5, 2019
1 parent edd3eaa commit 26e65b0
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ practices.</p>
- [The problem](#the-problem)
- [This solution](#this-solution)
- [Installation](#installation)
- [Suppressing unnecessary warnings on React DOM 16.8](#suppressing-unnecessary-warnings-on-react-dom-168)
- [Examples](#examples)
- [Basic Example](#basic-example)
- [Complex Example](#complex-example)
Expand Down Expand Up @@ -108,6 +109,36 @@ use [the custom jest matchers](https://github.com/testing-library/jest-dom).

> [**Docs**](https://testing-library.com/react)
### Suppressing unnecessary warnings on React DOM 16.8

There is a known compatibility issue with React DOM 16.8 where you will see the
following warning:

```
Warning: An update to ComponentName inside a test was not wrapped in act(...).
```

If you cannot upgrade to React DOM 16.9, you may suppress the warnings by adding
the following snippet to your test configuration:

```js
// this is just a little hack to silence a warning that we'll get until react
// fixes this: https://github.com/facebook/react/pull/14853
const originalError = console.error
beforeAll(() => {
console.error = (...args) => {
if (/Warning.*not wrapped in act/.test(args[0])) {
return
}
originalError.call(console, ...args)
}
})

afterAll(() => {
console.error = originalError
})
```

## Examples

### Basic Example
Expand Down

0 comments on commit 26e65b0

Please sign in to comment.