data
data copied to clipboard
WarpDrive assumes browser APIs that break in non-DOM environments (React Native)
When trying to run WarpDrive inside a React Native environment (as part of an experiment), the current implementation fails because it directly accesses browser-specific globals like window.addEventListener and document.visibilityState.
TypeError: window.addEventListener is not a function
TypeError: Cannot read properties of undefined (reading 'visibilityState')
Missing DOMException
These occur inside:
- RequestSubscription (listening for visibility and network events) https://github.com/warp-drive-data/warp-drive/blob/a9343d500e2490dd60ddd442c9c6448754fab13b/warp-drive-packages/core/src/signals/request-subscription.ts#L486
React Native doesn’t have window or document, so these assumptions cause failures even though the rest ofWarp Drive (signals, store, request manager, etc.) works fine once the environment is polyfilled.
How other libraries solve this
TanStack solves this by exposing onlineManager and focusManager - https://tanstack.com/query/v5/docs/framework/react/react-native. You can then use your React Native libraries to update their states