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
2 changes: 2 additions & 0 deletions packages/mobile/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Order is important, please don't change it unless you know what you're doing :D
import 'node-libs-react-native/globals'
import 'src/missingGlobals'
import 'src/forceCommunityAsyncStorage'
import { AppRegistry } from 'react-native'
import Logger from 'src/utils/Logger'
import App from 'src/app/App'
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/src/apollo/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import AsyncStorage from '@react-native-community/async-storage'
import ApolloClient from 'apollo-boost'
import { InMemoryCache, IntrospectionFragmentMatcher } from 'apollo-cache-inmemory'
import { persistCache } from 'apollo-cache-persist'
import { AsyncStorage } from 'react-native'
import introspectionQueryResultData from 'src/apollo/fragmentTypes.json'
import config from 'src/geth/networkConfig'
import Logger from 'src/utils/Logger'
Expand Down
15 changes: 15 additions & 0 deletions packages/mobile/src/forceCommunityAsyncStorage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import AsyncStorage from '@react-native-community/async-storage'
import ReactNative from 'react-native'

// Monkey patch React Native so it uses the community implementation of AsyncStorage.
// This is to fix the problem of loosing AsyncStorage data on iOS when some modules
// import AsyncStorage from React Native Core and some others import from React Native Community.
// Since both implementations currently write to the same file on disk, the last one to write wins
// and erases the existing data written by the other.
// See https://github.com/react-native-community/async-storage/issues/118#issuecomment-500138053
// TODO: remove this once React Native removes AsyncStorage from Core.
Object.defineProperty(ReactNative, 'AsyncStorage', {
get() {
return AsyncStorage
},
})