-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(code-block): fix local-storage breakage #735
Conversation
π¦ Changeset detectedLatest commit: cbfefc0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
π¦ Canary Packages PublishedLatest commit: cbfefc0 Published 2 packages@hashicorp/react-code-block@6.1.1-canary-20221003145352
@hashicorp/react-intro@0.4.2-canary-20221003145352
|
return window.localStorage.setItem(key, value) | ||
} | ||
|
||
const safeLocalStorage = { getItem, setItem } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this utility function to try to keep the provider
code simple, while handling the case where window.localStorage
is not available.
@BRKalow This fix targets the Let me know what you think π |
ποΈ Asana Task
π Preview Link
Description
This PR fixes an issue where
code-block
could cause app breakage by trying to accesswindow.localStorage
without first confirming thatwindow.localStorage
is available.window.localStorage
is not available if the visitor has blocked all cookies.I've proven out this change in hashicorp/dev-portal#1147.
PR Checklist π
Items in this checklist may not may not apply to your PR, but please consider each item carefully.