Skip to content

Commit

Permalink
Merge pull request #3372 from PenghaiZhang/bugfix/do-not-update-state…
Browse files Browse the repository at this point in the history
…-when-search-result-unmounted

bugfix: do not update SearchResult state when it is unmounted
  • Loading branch information
PenghaiZhang authored Sep 7, 2021
2 parents 3d4b567 + b740e31 commit 78ff3d4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion react-front-end/tsrc/search/components/SearchResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export default function SearchResult({
setDrmCheckOnSuccessHandler(() => onSuccess);

useEffect(() => {
let mounted = true;
(async () => {
// If there is nothing requiring DRM permission check then return undefined.
const dialog = drmCheckOnSuccessHandler
Expand All @@ -203,8 +204,14 @@ export default function SearchResult({
)
: undefined;

setDrmDialog(dialog);
if (mounted) {
setDrmDialog(dialog);
}
})();

return () => {
mounted = false;
};
}, [drmCheckOnSuccessHandler, uuid, version, drmStatus]);

const handleSelectResource = (
Expand Down

0 comments on commit 78ff3d4

Please sign in to comment.