Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Check for window object before assigning property
Browse files Browse the repository at this point in the history
  • Loading branch information
joeattardi committed Mar 4, 2023
1 parent 03061da commit 72131b3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/picmo/src/data/emojiData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { computeHash, isSessionStorageAvailable } from '../util';
import { createStorage } from '../webStorageShim';
import { InMemoryStoreFactory } from './InMemoryStore';

if (!isSessionStorageAvailable()) {
if (!isSessionStorageAvailable() && typeof window !== 'undefined') {
// emojibase relies on session storage being available for caching data.
// No way to disable this so we'll make a fake implementation. Caching won't work as expected
// but at least the picker will run.
Expand Down
2 changes: 1 addition & 1 deletion packages/picmo/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const defaultOptions: Partial<PickerOptions> = {
custom: []
};

if (!isLocalStorageAvailable()) {
if (!isLocalStorageAvailable() && typeof window !== 'undefined') {
console.warn('[picmo] localStorage not available, falling back to simple in-memory storage');
Object.defineProperty(window, 'localStorage', {
value: createStorage()
Expand Down

0 comments on commit 72131b3

Please sign in to comment.