Fix some useEffect() cleanup issues
This commit is contained in:
parent
1983512fef
commit
1ab8285ad3
6 changed files with 38 additions and 2 deletions
|
@ -33,13 +33,18 @@ export function Component({
|
|||
const [autocompleteOptions, setAutocompleteOptions] = useState<string[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
let aborted = false
|
||||
store.api.app.bsky
|
||||
.getUserFollows({
|
||||
user: store.me.did || '',
|
||||
})
|
||||
.then(res => {
|
||||
if (aborted) return
|
||||
setFollowedUsers(res.data.follows)
|
||||
})
|
||||
return () => {
|
||||
aborted = true
|
||||
}
|
||||
})
|
||||
|
||||
const onChangeText = (newText: string) => {
|
||||
|
|
|
@ -29,15 +29,21 @@ export function UserInfoText({
|
|||
const [didFail, setFailed] = useState<boolean>(false)
|
||||
|
||||
useEffect(() => {
|
||||
let aborted = false
|
||||
// TODO use caching to reduce loads
|
||||
store.api.app.bsky.getProfile({user: did}).then(
|
||||
v => {
|
||||
if (aborted) return
|
||||
setProfile(v.data)
|
||||
},
|
||||
_err => {
|
||||
if (aborted) return
|
||||
setFailed(true)
|
||||
},
|
||||
)
|
||||
return () => {
|
||||
aborted = true
|
||||
}
|
||||
}, [did, store.api.app.bsky])
|
||||
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue