Skip to content

Commit ecdce03

Browse files
authored
React: gracefully handle last handle setting for block-all-cookies (#213)
1 parent 61c77e0 commit ecdce03

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

packages/react/src/hooks/use-last-handle.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ export const useLastHandle: UseLastHandle = () => {
4343
if (!isHandle(handle)) {
4444
return
4545
}
46-
47-
window.localStorage.setItem(
48-
STORAGE_LAST_HANDLE_KEY,
49-
JSON.stringify(handle)
50-
);
46+
47+
try {
48+
window.localStorage.setItem(
49+
STORAGE_LAST_HANDLE_KEY,
50+
JSON.stringify(handle)
51+
);
52+
} catch {
53+
// do nothing
54+
}
5155
}, []);
5256

5357
useEffect(() => {

0 commit comments

Comments
 (0)