Skip to content

Commit e0ac255

Browse files
arniuflovilmart
authored andcommitted
Support React Native < 0.43 once again (#461)
1 parent ad02823 commit e0ac255

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ For React Native applications, include `'parse/react-native'`:
3636
var Parse = require('parse/react-native');
3737
```
3838

39-
> As of `v1.10`, Parse-SDK-JS supports React Native 0.43+. Please use `v1.9.2` for previous versions of React Native.
40-
4139
## License
4240

4341
```

src/StorageController.react-native.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@
1010
*/
1111

1212
import ParsePromise from './ParsePromise';
13+
1314
// RN packager nonsense
14-
import { AsyncStorage } from 'react-native/Libraries/react-native/react-native-implementation';
15+
let AsyncStorage;
16+
try {
17+
// for React Native 0.43+
18+
AsyncStorage = require('react-native/Libraries/react-native/react-native-implementation').AsyncStorage;
19+
} catch (error) {
20+
AsyncStorage = require('react-native/Libraries/react-native/react-native.js').AsyncStorage;
21+
}
1522

1623
var StorageController = {
1724
async: 1,

src/__tests__/Storage-test.js

+5
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,15 @@ var mockRNStorageInterface = {
2929
},
3030
};
3131

32+
// for React Native 0.43+
3233
jest.mock('react-native/Libraries/react-native/react-native-implementation', () => {
3334
return {AsyncStorage: mockRNStorageInterface};
3435
}, {virtual: true});
3536

37+
jest.mock('react-native/Libraries/react-native/react-native.js', () => {
38+
return {AsyncStorage: mockRNStorageInterface};
39+
}, {virtual: true});
40+
3641
var CoreManager = require('../CoreManager');
3742
var ParsePromise = require('../ParsePromise').default;
3843

0 commit comments

Comments
 (0)