-
Notifications
You must be signed in to change notification settings - Fork 158
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
Conversation
🦋 Changeset detectedLatest commit: 619bec1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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]>
2118cbd to
4a74163
Compare
* test: assert DefaultOnlineDetector works in React Native environments (issue #1013) * OnlineDetector for RN * ci: apply automated fixes * Changeset * Offline transactions demo app for RN * Remove .expo folder from tracking * Updated .gitignore to ignore .expo cache * Add screencast to readme * ci: apply automated fixes * Fix versioning problems * Sherif fix package versions --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
|
🎉 This PR has been released! Thank you for your contribution! |
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.