Skip to content

Commit 8327be8

Browse files
committed
s/isActive/isMounted/ everywhere
1 parent 68ef5de commit 8327be8

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ useAsyncEffect(callback, onDestroy, dependencies?);
3838
- The async callback will receive a single function to check whether the callback is still active:
3939
4040
```javascript
41-
useAsyncEffect(async isActive => {
41+
useAsyncEffect(async isMounted => {
4242
const data1 = await fn1();
43-
if (!isActive()) return;
43+
if (!isMounted()) return;
4444

4545
const data2 = await fn2();
46-
if (!isActive()) return;
46+
if (!isMounted()) return;
4747

4848
doSomething(data1, data2);
4949
});
@@ -70,9 +70,9 @@ useAsyncEffect(() => fetch('url'), (result) => console.log(result));
7070
7171
Making sure it's still active before updating component state
7272
```javascript
73-
useAsyncEffect(async isActive => {
73+
useAsyncEffect(async isMounted => {
7474
const data = await fetch(`/users/${id}`).then(res => res.json());
75-
if (!isActive()) return;
75+
if (!isMounted()) return;
7676
setUser(data);
7777
}, [id]);
7878
```

index.js.flow

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
declare module 'use-async-effect' {
22
declare function useAsyncEffect(
3-
effect: (isActive: () => boolean) => any | Promise<any>,
3+
effect: (isMounted: () => boolean) => any | Promise<any>,
44
inputs?: any[]
55
): void;
66

77
declare function useAsyncEffect<V>(
8-
effect: (isActive: () => boolean) => V | Promise<V>,
8+
effect: (isMounted: () => boolean) => V | Promise<V>,
99
destroy?: ?(result?: V) => void,
1010
inputs?: any[]
1111
): void;

types/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import useEffect, { useAsyncEffect } from 'use-async-effect';
44
useAsyncEffect();
55

66
// $ExpectType void
7-
useAsyncEffect((isActive) => {});
7+
useAsyncEffect((isMounted) => {});
88

99
// $ExpectType void
1010
useEffect(async () => {});

0 commit comments

Comments
 (0)