Skip to content

Commit

Permalink
setState + shallow rendering are now working fine
Browse files Browse the repository at this point in the history
Updating docs regarding React updates on Shallow Rendering: facebook/react#4019 (comment)
  • Loading branch information
igorsantos07 committed Mar 1, 2016
1 parent 06ac006 commit 4ca239f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/recipes/WritingTests.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,9 @@ describe('components', () => {
})
```

#### Fixing Broken `setState()`
#### Fixing Broken `setState()` in older React versions

Shallow rendering currently [throws an error if `setState` is called](https://github.com/facebook/react/issues/4019). React seems to expect that, if you use `setState`, the DOM is available. To work around the issue, we use jsdom so React doesn’t throw the exception when the DOM isn’t available. Here’s how to [set it up](https://github.com/facebook/react/issues/5046#issuecomment-146222515):
In React <= 0.13, 0.14.4 and 0.14.5, Shallow rendering [used to throw an error if `setState` is called](https://github.com/facebook/react/issues/4019). React seems to expect that, if you use `setState`, the DOM is available. To work around the issue, we use jsdom so React doesn’t throw the exception when the DOM isn’t available. Here’s how to [set it up](https://github.com/facebook/react/issues/5046#issuecomment-146222515):

```
npm install --save-dev jsdom
Expand Down

0 comments on commit 4ca239f

Please sign in to comment.