Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quiet-snakes-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@react-native-async-storage/async-storage": major
---

Support 0.74 (by migrating off deprecated `onCatalystInstanceDestroy`) — unfortunately, this also means that we must bump the minimum supported version to 0.65
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.GuardedAsyncTask;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
Expand All @@ -34,7 +33,7 @@

@ReactModule(name = AsyncStorageModule.NAME)
public final class AsyncStorageModule
extends NativeAsyncStorageModuleSpec implements ModuleDataCleaner.Cleanable, LifecycleEventListener {
extends NativeAsyncStorageModuleSpec implements ModuleDataCleaner.Cleanable {

// changed name to not conflict with AsyncStorage from RN repo
public static final String NAME = "RNCAsyncStorage";
Expand All @@ -60,11 +59,12 @@ public AsyncStorageModule(ReactApplicationContext reactContext) {
@VisibleForTesting
AsyncStorageModule(ReactApplicationContext reactContext, Executor executor) {
super(reactContext);

// The migration MUST run before the AsyncStorage database is created for the first time.
AsyncStorageExpoMigration.migrate(reactContext);

this.executor = new SerialExecutor(executor);
reactContext.addLifecycleEventListener(this);

// Creating the database MUST happen after the migration.
mReactDatabaseSupplier = ReactDatabaseSupplier.getInstance(reactContext);
}
Expand All @@ -81,8 +81,10 @@ public void initialize() {
}

@Override
public void onCatalystInstanceDestroy() {
public void invalidate() {
mShuttingDown = true;
// ensure we close database when activity is destroyed
mReactDatabaseSupplier.closeDatabase();
}

@Override
Expand All @@ -93,18 +95,6 @@ public void clearSensitiveData() {
mReactDatabaseSupplier.clearAndCloseDatabase();
}

@Override
public void onHostResume() {}

@Override
public void onHostPause() {}

@Override
public void onHostDestroy() {
// ensure we close database when activity is destroyed
mReactDatabaseSupplier.closeDatabase();
}

/**
* Given an array of keys, this returns a map of (key, value) pairs for the keys found, and
* (key, null) for the keys that haven't been found.
Expand Down
2 changes: 1 addition & 1 deletion packages/default-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"merge-options": "^3.0.4"
},
"peerDependencies": {
"react-native": "^0.0.0-0 || >=0.60 <1.0"
"react-native": "^0.0.0-0 || >=0.65 <1.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4238,7 +4238,7 @@ __metadata:
typescript: "npm:^5.3.0"
webdriverio: "npm:^8.24.0"
peerDependencies:
react-native: ^0.0.0-0 || >=0.60 <1.0
react-native: ^0.0.0-0 || >=0.65 <1.0
languageName: unknown
linkType: soft

Expand Down
Loading