Skip to content

useLocaleStorageValue should not do anything server side#216

Merged
nikomakela merged 2 commits into
mainfrom
LIIKUNTA-764-fix-console-message
Nov 26, 2025
Merged

useLocaleStorageValue should not do anything server side#216
nikomakela merged 2 commits into
mainfrom
LIIKUNTA-764-fix-console-message

Conversation

@nikomakela

Copy link
Copy Markdown
Contributor

LIIKUNTA-764.

Upgrade the (patch) version number.

};

// Utility function to check if we are in a browser environment
const isBrowser = typeof window !== 'undefined';

@karisal-anders karisal-anders Nov 26, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
const isBrowser = typeof window !== 'undefined';
const isBrowser = () => typeof window !== 'undefined';

and changing the if (!isBrowser) { to if (!isBrowser()) {.
Wouldn't that be safer because the window's value would be evaluated each time the isBrowser function is run, not just once?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yea, and actually, the second function is void, so it should not return null.

@nikomakela nikomakela force-pushed the LIIKUNTA-764-fix-console-message branch from 60e22d6 to e21e18b Compare November 26, 2025 07:56
@nikomakela nikomakela force-pushed the LIIKUNTA-764-fix-console-message branch from e21e18b to e3a04b6 Compare November 26, 2025 07:58
@nikomakela nikomakela merged commit aae014a into main Nov 26, 2025
1 check passed
@nikomakela nikomakela deleted the LIIKUNTA-764-fix-console-message branch November 26, 2025 09:29
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