-
Notifications
You must be signed in to change notification settings - Fork 910
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
Use ReactNativeAsyncStorage from community package. #7128
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@firebase/auth': major | ||
'firebase': major | ||
--- | ||
|
||
Change `getAuth()` in the React Native bundle to default to importing `AsyncStorage` from `@react-native-async-storage/async-storage` instead of from the `react-native` core package (which has recently removed it). |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,15 +22,14 @@ | |
* just use index.ts | ||
*/ | ||
|
||
import * as ReactNative from 'react-native'; | ||
|
||
import { FirebaseApp, getApp, _getProvider } from '@firebase/app'; | ||
import { Auth, Persistence } from './src/model/public_types'; | ||
import { Auth } from './src/model/public_types'; | ||
|
||
import { initializeAuth } from './src'; | ||
import { registerAuth } from './src/core/auth/register'; | ||
import { ClientPlatform } from './src/core/util/version'; | ||
import { getReactNativePersistence } from './src/platform_react_native/persistence/react_native'; | ||
import ReactNativeAsyncStorage from '@react-native-async-storage/async-storage'; | ||
|
||
// Core functionality shared by all clients | ||
export * from './index.shared'; | ||
|
@@ -50,28 +49,6 @@ export { | |
// MFA | ||
export { PhoneMultiFactorGenerator } from './src/platform_browser/mfa/assertions/phone'; | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For reviewers: This section was added as a hack to import from react-native core by default (which will normally show a warning), but not show the warning if the user overrides the default and provides the newer community version of AsyncStorage. Since this change makes the community package the default, this isn't needed anymore. |
||
* An implementation of {@link Persistence} of type 'LOCAL' for use in React | ||
* Native environments. | ||
* | ||
* @public | ||
*/ | ||
export const reactNativeLocalPersistence: Persistence = | ||
getReactNativePersistence({ | ||
getItem(...args) { | ||
// Called inline to avoid deprecation warnings on startup. | ||
return ReactNative.AsyncStorage.getItem(...args); | ||
}, | ||
setItem(...args) { | ||
// Called inline to avoid deprecation warnings on startup. | ||
return ReactNative.AsyncStorage.setItem(...args); | ||
}, | ||
removeItem(...args) { | ||
// Called inline to avoid deprecation warnings on startup. | ||
return ReactNative.AsyncStorage.removeItem(...args); | ||
} | ||
}); | ||
|
||
export { getReactNativePersistence }; | ||
|
||
export function getAuth(app: FirebaseApp = getApp()): Auth { | ||
|
@@ -82,7 +59,7 @@ export function getAuth(app: FirebaseApp = getApp()): Auth { | |
} | ||
|
||
return initializeAuth(app, { | ||
persistence: reactNativeLocalPersistence | ||
persistence: getReactNativePersistence(ReactNativeAsyncStorage) | ||
}); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3050,6 +3050,13 @@ | |
resolved "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" | ||
integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA= | ||
|
||
"@react-native-async-storage/[email protected]": | ||
version "1.17.12" | ||
resolved "https://registry.npmjs.org/@react-native-async-storage/async-storage/-/async-storage-1.17.12.tgz#a39e4df5b06795ce49b2ca5b7ca9b8faadf8e621" | ||
integrity sha512-BXg4OxFdjPTRt+8MvN6jz4muq0/2zII3s7HeT/11e4Zeh3WCgk/BleLzUcDfVqF3OzFHUqEkSrb76d6Ndjd/Nw== | ||
dependencies: | ||
merge-options "^3.0.4" | ||
|
||
"@rollup/[email protected]": | ||
version "3.1.9" | ||
resolved "https://registry.npmjs.org/@rollup/plugin-alias/-/plugin-alias-3.1.9.tgz#a5d267548fe48441f34be8323fb64d1d4a1b3fdf" | ||
|
@@ -12251,6 +12258,13 @@ [email protected]: | |
resolved "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" | ||
integrity sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E= | ||
|
||
merge-options@^3.0.4: | ||
version "3.0.4" | ||
resolved "https://registry.npmjs.org/merge-options/-/merge-options-3.0.4.tgz#84709c2aa2a4b24c1981f66c179fe5565cc6dbb7" | ||
integrity sha512-2Sug1+knBjkaMsMgf1ctR1Ujx+Ayku4EdJN4Z+C2+JzoeF7A3OZ9KM2GY0CpQS51NR61LTurMJrRKPhSs3ZRTQ== | ||
dependencies: | ||
is-plain-obj "^2.1.0" | ||
|
||
merge-stream@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" | ||
|
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.
I'm curious why this was exposed externally. Looks like the index.rn.ts was using "reactNativeLocalPersistence" as part of getAuth, but the developer wasn;t directly passing it as a param to initializeAuth, were they?
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.
I don't actually remember the reason, maybe in case the users wanted to call it explicitly, or if they wanted to add multiple persistences (use the array format) for some reason, although I can't think of another persistence you'd want to add for React Native.