React Native build does not maintain arrow functions and causes error with AsyncStorage #1580
Closed
4 tasks done
Labels
type:bug
Impaired feature or lacking behavior that is likely assumed
New Issue Checklist
Issue Description
When using the AsyncStorage backend for
react-native
, you would getUnhandled promise rejection: TypeError: this.getAsyncStorage is not a function.
when trying to save objects.Inspecting the distribution file
node_modules/parse/lib/react-native/StorageController.react-native.js
shows that all arrow functions have been transformed into regular functions, causing thethis
context to become ones of the callback functions and making everything break.Replacing all the unnamed functions with arrow functions as originally written in the source restores the same, functioning behaviour.
This appears to be a problem with the babel transpiler during the publish process (the file clearly has
_interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
at the top).Steps to reproduce
[email protected]
into a react native project.await object.save()
orawait object.saveEventually()
on the objectActual Outcome
[Unhandled promise rejection: TypeError: this.getAsyncStorage is not a function. (In 'this.getAsyncStorage()', 'this.getAsyncStorage' is undefined)]
node_modules/parse/lib/react-native/StorageController.react-native.js
and replacing all the unnamed functions with arrow functions as originally written in the source restores the same, functioning behaviour.Expected Outcome
Environment
Server
5.2.8
Mac OS 12.4
local host
Client
3.5.0-alpha.6
Logs
The text was updated successfully, but these errors were encountered: