Trying to work out using Parse with React Native and using Back4App as my BaaS. Running into a problem when setting up my asyncstorage (from react native).
Parse.setAsyncStorage(AsyncStorage);
//Paste below the Back4App Application ID AND the JavaScript KEY
Parse.initialize('myappid', 'sdk');
//Point to Back4App Parse API address
Parse.serverURL = 'https://parseapi.back4app.com/';
This is the initialization code I am trying to run. Unfortunatly, I am running into this error:
App.js:14 Uncaught TypeError:
parse_react_native__WEBPACK_IMPORTED_MODULE_5___default.a.setAsyncStorage is not a function
Trying different versions of parse, different imports, different storages, nothing works. Here are my imports:
import AsyncStorage from '@react-native-async-storage/async-storage';
import Parse from 'parse/react-native';
Additional information: I have another project working but it is running expo 40 and parse 2.19 with asyncstorage 1.17.9. this project is running expo 46 and parse 3.4.3 with asyncstorage 1.17.10.
I want to use expo 46 for its additional features. I tried downgrading to the same versions of parse and asyncstorage but without any success.
CodePudding user response:
If anyone ever comes across this problem, update the import for parse to be
import Parse from 'parse/react-native.js';
If an error about event emitter occurs after that, please go to event emitter in the node modules and fix the import and export to be ES6 compatible.
CodePudding user response:
in your file you incorrectly imported Parse
. imports Parse
with brackets so React knows you're taking the function instead of the whole thing.
Instead of
import Parse from 'parse/react-native';
you should use
import { Parse } from 'react';