Skip to content

Commit

Permalink
Fix error on unmount in syncplay menu
Browse files Browse the repository at this point in the history
  • Loading branch information
thornbill committed Sep 20, 2023
1 parent dbd068b commit 55a2ca3
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,23 @@ const SyncPlayMenu: FC<SyncPlayMenuProps> = ({
}, []);

useEffect(() => {
let isMounted = true;

const fetchGroups = async () => {
if (api) {
setGroups((await getSyncPlayApi(api).syncPlayGetGroups()).data);
const response = await getSyncPlayApi(api).syncPlayGetGroups();
if (isMounted) setGroups(response.data);
}
};

fetchGroups()
.catch(err => {
console.error('[SyncPlayMenu] unable to fetch SyncPlay groups', err);
});

return () => {
isMounted = false;
};
}, [ api ]);

const onGroupAddClick = useCallback(() => {
Expand Down

0 comments on commit 55a2ca3

Please sign in to comment.