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(themecontext): fixing ReferenceError: window is not defined error with Next.js #652

Merged
merged 3 commits into from
Mar 5, 2023

Conversation

fsioni
Copy link
Contributor

@fsioni fsioni commented Mar 5, 2023

Description

The variable userPreferenceIsDark was initialized with a value from the window object. This was causing an error with Next because of SSR. I added the check of the window, if it's on the server side the value is set to false

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change contains documentation update

How Has This Been Tested?

On my Next.js project that was causing the error.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

fsioni and others added 3 commits March 5, 2023 00:52
…r with Next.js

The variable `userPreferenceIsDark` was initialized with a value from the window object. This was causing an error with Next because of SSR. I added the check of the window, if it's on the server side, set to white
…or with Next.js

The variable`userPreferenceIsDark` was initialized with a value from the window object. This was
causing an error with Next because of SSR. I added the check of the window, if it's on the server
side the value is set to `false`
… userPreferenceIsDark_error

# Conflicts:
#	src/lib/components/Flowbite/ThemeContext.tsx
@codecov
Copy link

codecov bot commented Mar 5, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change

Comparison is base (863a789) 99.42% compared to head (cfbf949) 99.42%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #652   +/-   ##
=======================================
  Coverage   99.42%   99.42%           
=======================================
  Files         130      130           
  Lines        6413     6413           
  Branches      477      477           
=======================================
  Hits         6376     6376           
  Misses         37       37           
Impacted Files Coverage Δ
src/lib/components/Flowbite/ThemeContext.tsx 85.93% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@tulup-conner tulup-conner left a comment

Choose a reason for hiding this comment

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

Thanks!

@tulup-conner tulup-conner merged commit 8fd9ddc into themesberg:main Mar 5, 2023
@fsioni fsioni deleted the userPreferenceIsDark_error branch March 5, 2023 00:20
@tulup-conner tulup-conner added this to the 1.0.0 milestone Mar 5, 2023
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