From 913a3b0fa8f277d7ca617cc16942c04e20b005f5 Mon Sep 17 00:00:00 2001 From: Beau Cameron Date: Mon, 10 Oct 2022 10:06:01 -0600 Subject: [PATCH] Adding mount logic to error handler --- .../src/webparts/pnPjsExample/hooks/useDocuments.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/samples/react-pnp-js-hooks-sample/src/webparts/pnPjsExample/hooks/useDocuments.ts b/samples/react-pnp-js-hooks-sample/src/webparts/pnPjsExample/hooks/useDocuments.ts index 56d4d6cbb..ea96d4874 100644 --- a/samples/react-pnp-js-hooks-sample/src/webparts/pnPjsExample/hooks/useDocuments.ts +++ b/samples/react-pnp-js-hooks-sample/src/webparts/pnPjsExample/hooks/useDocuments.ts @@ -61,7 +61,9 @@ const useDocuments = () => { ); } } catch (err) { - setError(true); + if (mounted) { + setError(true); + } Logger.write( `${LOG_SOURCE} (getting files useEffect) - ${JSON.stringify(err)} - `, LogLevel.Error @@ -114,7 +116,9 @@ const useDocuments = () => { setError(false); } } catch (err) { - setError(true); + if (mounted) { + setError(true); + } Logger.write( `${LOG_SOURCE} (updating titles) - ${JSON.stringify(err)} - `, LogLevel.Error