Skip to content

Commit 6e474a5

Browse files
committed
Fix linting.
1 parent e65e080 commit 6e474a5

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/useAsync.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,22 @@ const useAsync = (opts, init) => {
4747
const isPreInitialized = initialValue && counter.current === 0
4848
if (promiseFn && !isPreInitialized) {
4949
start()
50-
promiseFn(options).then(handleResolve(counter.current), handleReject(counter.current))
50+
return promiseFn(options).then(handleResolve(counter.current), handleReject(counter.current))
5151
}
5252
}
5353

5454
const run = (...args) => {
5555
if (deferFn) {
5656
start()
5757
lastArgs.current = args
58-
return deferFn(...args, options).then(handleResolve(counter.current), handleReject(counter.current))
58+
return deferFn(...args, options).then(
59+
handleResolve(counter.current),
60+
handleReject(counter.current)
61+
)
5962
}
6063
}
6164

62-
useEffect(load, [promiseFn, watch])
65+
useEffect(() => load() && undefined, [promiseFn, watch])
6366
useEffect(() => () => (isMounted.current = false), [])
6467

6568
return useMemo(

src/useAsync.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ describe("useAsync", () => {
8383
test("passes reload function that re-runs the promise", async () => {
8484
const promiseFn = jest.fn().mockReturnValue(resolveTo("done"))
8585
const component = (
86-
<Async promiseFn={promiseFn}>{({ reload }) => <button onClick={reload}>reload</button>}</Async>
86+
<Async promiseFn={promiseFn}>
87+
{({ reload }) => <button onClick={reload}>reload</button>}
88+
</Async>
8789
)
8890
const { getByText } = render(component)
8991
flushEffects()
@@ -319,4 +321,4 @@ describe("useAsync", () => {
319321
await waitForElement(() => getByText("outer undefined"))
320322
await waitForElement(() => getByText("outer inner"))
321323
})
322-
})
324+
})

0 commit comments

Comments
 (0)