-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Do not try to load the expo-file-system package on the Web targe…
…t since it's not supported (#158)
- Loading branch information
1 parent
50f681d
commit 9cb9ec7
Showing
2 changed files
with
11 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
import type ExpoFileSystem from 'expo-file-system' | ||
import { Platform } from 'react-native' | ||
|
||
export let OptionalExpoFileSystem: typeof ExpoFileSystem | undefined = undefined | ||
|
||
try { | ||
OptionalExpoFileSystem = require('expo-file-system') // No Web support | ||
// do not try to load expo-file-system on web, otherwise it will throw an error | ||
// Error: The method or property expo-file-system.writeAsStringAsync is not available on web | ||
// See https://github.com/PostHog/posthog-js-lite/issues/140 | ||
// Once expo-file-system is supported on web, we can remove this try/catch block | ||
// For now, use the react-native-async-storage/async-storage package instead | ||
if (Platform.OS !== 'web') { | ||
OptionalExpoFileSystem = require('expo-file-system') // No Web support | ||
} | ||
} catch (e) {} |