Skip to content
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(use-storage): using with SSR #2053

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix(use-storage): using with SSR #2053

wants to merge 1 commit into from

Conversation

gmonte
Copy link

@gmonte gmonte commented Jun 20, 2024

I am using Nextjs 14 and I am receiving some errors on build time because this package are using window directly when getting the storage. I created the getStorage() function that use canUseDOM to check if we can access window and it returns the corresponding storage.

Now I am able to use it with Nextjs.

Copy link

changeset-bot bot commented Jun 20, 2024

⚠️ No Changeset found

Latest commit: e39c020

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

codecov bot commented Jun 20, 2024

Codecov Report

Attention: Patch coverage is 17.64706% with 14 lines in your changes missing coverage. Please review.

Project coverage is 76.13%. Comparing base (cc09c01) to head (e39c020).

Files Patch % Lines
packages/use-storage/src/index.ts 17.64% 13 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2053      +/-   ##
==========================================
- Coverage   77.48%   76.13%   -1.35%     
==========================================
  Files          25       25              
  Lines         755      771      +16     
  Branches       94       97       +3     
==========================================
+ Hits          585      587       +2     
- Misses        162      175      +13     
- Partials        8        9       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@philibea
Copy link
Collaborator

Hello @gmonte, first thanks for your contribution.

it's will be review after 2 things:

  • add a changeset that describe your change
  • add some test to keep our code coverage under the right threshold

@@ -24,6 +24,34 @@ const canUseDOM =
typeof window.sessionStorage !== 'undefined'
)

const createMemoryStorage = (): Storage => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing unit test on this part

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants