Skip to content

Support React Native < 0.43 once again #461

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

Merged
merged 1 commit into from
Oct 21, 2017
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: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ For React Native applications, include `'parse/react-native'`:
var Parse = require('parse/react-native');
```

> As of `v1.10`, Parse-SDK-JS supports React Native 0.43+. Please use `v1.9.2` for previous versions of React Native.

## License

```
Expand Down
9 changes: 8 additions & 1 deletion src/StorageController.react-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@
*/

import ParsePromise from './ParsePromise';

// RN packager nonsense
import { AsyncStorage } from 'react-native/Libraries/react-native/react-native-implementation';
let AsyncStorage;
try {
// for React Native 0.43+
AsyncStorage = require('react-native/Libraries/react-native/react-native-implementation').AsyncStorage;
} catch (error) {
AsyncStorage = require('react-native/Libraries/react-native/react-native.js').AsyncStorage;
}

var StorageController = {
async: 1,
Expand Down
5 changes: 5 additions & 0 deletions src/__tests__/Storage-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ var mockRNStorageInterface = {
},
};

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

jest.mock('react-native/Libraries/react-native/react-native.js', () => {
return {AsyncStorage: mockRNStorageInterface};
}, {virtual: true});

var CoreManager = require('../CoreManager');
var ParsePromise = require('../ParsePromise').default;

Expand Down