Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2f865be

Browse files
authored
Merge pull request #224 from LeviButcher/docfix
Apply prettier formatting and switch to new testing-lib name
2 parents ee24059 + 65064b4 commit 2f865be

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

‎docs/usage/basic-hooks.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ You may have also noticed that we also wrapped the `increment` call in `act`. Th
6565
how our hook will act in a browser, allowing us to update the values within it. For more details on
6666
`act`, please see the [React documentation](https://fb.me/react-wrap-tests-with-act).
6767

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
6969
happen so you cannot destructure its values as the assignment will make a copy locking into the
7070
value at that time.
7171

@@ -172,11 +172,11 @@ value changes for both the setup and cleanup of the `useEffect` call:
172172

173173
```js
174174
import { useEffect } from 'react'
175-
import { renderHook } from "react-hooks-testing-library"
175+
import { renderHook } from '@testing-library/react-hooks'
176176
import sideEffect from './sideEffect'
177177

178-
test("should clean up side effect", () => {
179-
let id = "first"
178+
test('should clean up side effect', () => {
179+
let id = 'first'
180180
const { rerender } = renderHook(() => {
181181
useEffect(() => {
182182
sideEffect.start(id)
@@ -186,11 +186,11 @@ test("should clean up side effect", () => {
186186
}, [id])
187187
})
188188

189-
id = "second"
189+
id = 'second'
190190
rerender()
191191

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)
194194
})
195195
```
196196

@@ -199,10 +199,10 @@ clean up the effect, allowing the test to pass as expected:
199199

200200
```js
201201
import { useEffect } from 'react'
202-
import { renderHook } from "react-hooks-testing-library"
202+
import { renderHook } from '@testing-library/react-hooks'
203203
import sideEffect from './sideEffect'
204204

205-
test("should clean up side effect", () => {
205+
test('should clean up side effect', () => {
206206
const { rerender } = renderHook(
207207
({ id }) => {
208208
useEffect(() => {
@@ -213,14 +213,14 @@ test("should clean up side effect", () => {
213213
}, [id])
214214
},
215215
{
216-
initialProps: { id: "first" }
216+
initialProps: { id: 'first' }
217217
}
218218
)
219219

220-
rerender({ id: "second" })
220+
rerender({ id: 'second' })
221221

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)
224224
})
225225
```
226226

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /