-
Notifications
You must be signed in to change notification settings - Fork 152
Fix offline transactions for React Native #1137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: f6203ce The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: 0 B Total Size: 90.5 kB ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 3.47 kB ℹ️ View Unchanged
|
|
Can we document this in the readme? |
|
@claude update the readme of the @tanstack/offline-transactions package to explain how to use that package for web vs for React Native as i did in this PR description. |
|
Claude finished @kevin-dp's task in 1m 22s —— View job Documentation updated successfullyTasks completed
SummaryI've updated the Installation Section
Platform Support Section (new)
Quick Start Section
Platform Support Section (bottom)
The documentation now clearly guides users on how to use the package in both web and React Native environments, matching the implementation details from this PR. --- • |
- Added separate installation instructions for web and React Native - Documented platform-specific OnlineDetector implementations - Clarified import path differences between platforms - Added React Native platform support details Co-authored-by: Kevin <[email protected]>
| ### React Native / Expo | ||
|
|
||
| ```typescript | ||
| import { startOfflineExecutor } from '@tanstack/offline-transactions/react-native' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@claude no need to repeat all the same code as we already show for the web example. Just show that the import is different.
Fix
@tanstack/offline-transactionsfor React Native / ExpoThis PR fixes #1013
Problem
The
DefaultOnlineDetectorattempted to use browser-specific APIs (window.addEventListener('online'),document.addEventListener('visibilitychange')) which don't exist in React Native. This caused errors when using the package in RN/Expo environments.Solution
Introduced platform-specific
OnlineDetectorimplementations:WebOnlineDetector- Uses browser APIs (window.online/offline,document.visibilitychange)ReactNativeOnlineDetector- Uses RN primitives (@react-native-community/netinfofor network status,AppStatefor foreground/background)The RN implementation is exposed via a separate entrypoint to avoid bundling RN modules for web users.
Usage
Web (unchanged):
React Native / Expo:
The RN entrypoint automatically uses
ReactNativeOnlineDetector. All other APIs remain the same.Peer Dependencies (for RN users)
The package declares
react-nativeand@react-native-community/netinfoas optional peer dependencies.