Skip to content

Commit

Permalink
fix: don't depend on react-native at runtime
Browse files Browse the repository at this point in the history
This causes issues in projects without the react-native dependency. For example, normal Next.js projects or even backend-only projects. Turns out Stashy can be used for more than just the examples!
  • Loading branch information
Pkmmte committed Dec 29, 2023
1 parent 00078a0 commit 471c844
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
/**
* © 2023 WavePlay <dev@waveplay.com>
*/
import { Platform } from 'react-native'
import { createRequire } from 'module'

const require = createRequire(import.meta.url)

let Platform: any
try {
Platform = require('react-native').Platform
} catch (e) {
Platform = { OS: 'web' }
}

export function isNative(): boolean {
return Platform.OS === 'android' || Platform.OS === 'ios'
Expand Down

1 comment on commit 471c844

@vercel
Copy link

@vercel vercel bot commented on 471c844 Dec 29, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.