Skip to content

Commit cd042a3

Browse files
committed
Use React Native AsyncStorage community package
1 parent a8be6ed commit cd042a3

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

packages/auth/index.rn.ts

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@
2222
* just use index.ts
2323
*/
2424

25-
import * as ReactNative from 'react-native';
26-
2725
import { FirebaseApp, getApp, _getProvider } from '@firebase/app';
28-
import { Auth, Persistence } from './src/model/public_types';
26+
import { Auth } from './src/model/public_types';
2927

3028
import { initializeAuth } from './src';
3129
import { registerAuth } from './src/core/auth/register';
3230
import { ClientPlatform } from './src/core/util/version';
3331
import { getReactNativePersistence } from './src/platform_react_native/persistence/react_native';
32+
import ReactNativeAsyncStorage from '@react-native-async-storage/async-storage';
3433

3534
// Core functionality shared by all clients
3635
export * from './index.shared';
@@ -50,28 +49,6 @@ export {
5049
// MFA
5150
export { PhoneMultiFactorGenerator } from './src/platform_browser/mfa/assertions/phone';
5251

53-
/**
54-
* An implementation of {@link Persistence} of type 'LOCAL' for use in React
55-
* Native environments.
56-
*
57-
* @public
58-
*/
59-
export const reactNativeLocalPersistence: Persistence =
60-
getReactNativePersistence({
61-
getItem(...args) {
62-
// Called inline to avoid deprecation warnings on startup.
63-
return ReactNative.AsyncStorage.getItem(...args);
64-
},
65-
setItem(...args) {
66-
// Called inline to avoid deprecation warnings on startup.
67-
return ReactNative.AsyncStorage.setItem(...args);
68-
},
69-
removeItem(...args) {
70-
// Called inline to avoid deprecation warnings on startup.
71-
return ReactNative.AsyncStorage.removeItem(...args);
72-
}
73-
});
74-
7552
export { getReactNativePersistence };
7653

7754
export function getAuth(app: FirebaseApp = getApp()): Auth {
@@ -82,7 +59,7 @@ export function getAuth(app: FirebaseApp = getApp()): Auth {
8259
}
8360

8461
return initializeAuth(app, {
85-
persistence: reactNativeLocalPersistence
62+
persistence: getReactNativePersistence(ReactNativeAsyncStorage)
8663
});
8764
}
8865

packages/auth/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
"@firebase/component": "0.6.4",
114114
"@firebase/logger": "0.4.0",
115115
"@firebase/util": "1.9.3",
116+
"@react-native-async-storage/async-storage": "1.17.12",
116117
"node-fetch": "2.6.7",
117118
"tslib": "^2.1.0"
118119
},
@@ -121,13 +122,13 @@
121122
"@firebase/app": "0.9.4",
122123
"@rollup/plugin-json": "4.1.0",
123124
"@rollup/plugin-strip": "2.1.0",
125+
"@types/express": "4.17.17",
124126
"chromedriver": "98.0.1",
125127
"rollup": "2.79.1",
126128
"rollup-plugin-sourcemaps": "0.6.3",
127129
"rollup-plugin-typescript2": "0.31.2",
128130
"selenium-webdriver": "4.8.0",
129-
"typescript": "4.7.4",
130-
"@types/express": "4.17.17"
131+
"typescript": "4.7.4"
131132
},
132133
"repository": {
133134
"directory": "packages/auth",

0 commit comments

Comments
 (0)