@@ -65,7 +65,7 @@ You may have also noticed that we also wrapped the `increment` call in `act`. Th
65
65
how our hook will act in a browser, allowing us to update the values within it. For more details on
66
66
` act ` , please see the [ React documentation] ( https://fb.me/react-wrap-tests-with-act ) .
67
67
68
- ** NOTE** : There's a gottcha with updates. ` renderHook ` mutates the value of ` current ` when updates
68
+ ** NOTE** : There's a gotcha with updates. ` renderHook ` mutates the value of ` current ` when updates
69
69
happen so you cannot destructure its values as the assignment will make a copy locking into the
70
70
value at that time.
71
71
@@ -172,11 +172,11 @@ value changes for both the setup and cleanup of the `useEffect` call:
172
172
173
173
``` js
174
174
import { useEffect } from ' react'
175
- import { renderHook } from " react-hooks- testing-library"
175
+ import { renderHook } from ' @ testing-library/react-hooks '
176
176
import sideEffect from ' ./sideEffect'
177
177
178
- test (" should clean up side effect" , () => {
179
- let id = " first"
178
+ test (' should clean up side effect' , () => {
179
+ let id = ' first'
180
180
const { rerender } = renderHook (() => {
181
181
useEffect (() => {
182
182
sideEffect .start (id)
@@ -186,11 +186,11 @@ test("should clean up side effect", () => {
186
186
}, [id])
187
187
})
188
188
189
- id = " second"
189
+ id = ' second'
190
190
rerender ()
191
191
192
- expect (sideEffect .get (" first" )).toBe (false )
193
- expect (sideEffect .get (" second" )).toBe (true )
192
+ expect (sideEffect .get (' first' )).toBe (false )
193
+ expect (sideEffect .get (' second' )).toBe (true )
194
194
})
195
195
```
196
196
@@ -199,10 +199,10 @@ clean up the effect, allowing the test to pass as expected:
199
199
200
200
``` js
201
201
import { useEffect } from ' react'
202
- import { renderHook } from " react-hooks- testing-library"
202
+ import { renderHook } from ' @ testing-library/react-hooks '
203
203
import sideEffect from ' ./sideEffect'
204
204
205
- test (" should clean up side effect" , () => {
205
+ test (' should clean up side effect' , () => {
206
206
const { rerender } = renderHook (
207
207
({ id }) => {
208
208
useEffect (() => {
@@ -213,14 +213,14 @@ test("should clean up side effect", () => {
213
213
}, [id])
214
214
},
215
215
{
216
- initialProps: { id: " first" }
216
+ initialProps: { id: ' first' }
217
217
}
218
218
)
219
219
220
- rerender ({ id: " second" })
220
+ rerender ({ id: ' second' })
221
221
222
- expect (thing .get (" first" )).toBe (false )
223
- expect (thing .get (" second" )).toBe (true )
222
+ expect (thing .get (' first' )).toBe (false )
223
+ expect (thing .get (' second' )).toBe (true )
224
224
})
225
225
```
226
226
0 commit comments