react-native: babelHelpers.objectDestructuringEmpty is not a function
I upgraded from RN 15 to RN 16 and now I get:
babelHelpers.objectDestructuringEmpty is not a function
:
Currently my .babelrc
files looks like:
{
"presets": ["react"],
"plugins": [
"transform-decorators-legacy",
"transform-es2015-classes",
"transform-export-extensions"
]
}
I previously also had es2015
in the presets
list but then I got: http://stackoverflow.com/questions/34112110/upgrade-to-react-native-0-16-error.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 2
- Comments: 30 (8 by maintainers)
Finally managed to get past this error. It turns out that I had code like this that needed to be removed:
I found this issue when having braces in place for destructuring, but without any values between the braces.
e.g.
const value = ({}) => { ... }
I believe Babel is simply complaining that the object is in fact empty, and does not have any values to destructure.
i had this issue also, the reason was
let {}=this.state
I had a similar issue because I used
{}
at some point, is this an issue with babel, and if so which repo should we report it.2 days ago we decided to upgrade RN from 0.14 to 0.19, after trial and errors we reached the
babelHelpers.objectDestructuringEmpty is not a function
error and found this thread. Thanks indeed. We had somefunction(state, {}) ...
in our codebase.Not sure if it’s a feature but it was working fine in Babel 5. Most likely Babel 6 is stricter.
@vigneshprabhu20 I just tried your solution and sadly I still have the same problem.
I fixed my problem thanks to your comments. My problem was that one of my render was like this :
_renderHeader = ({}) => {...}
and it should be like this :
_renderHeader = () => {...}
A fix is really needed for this 👍
I got this fix upon installing babel helper plugin.
Package.json: “devDependencies”: { “babel-cli”: “6.26.0”, “babel-plugin-external-helpers”: “^6.22.0”, … }
babelrc: { “presets”: [“react-native”, “flow”], “plugins”: [ “external-helpers”, … ] }
Reference to install this plugin: https://www.npmjs.com/package/babel-plugin-external-helpers
I had similar problem:
it works good in debug, but release build chased.
fixed by changing
{}
to_
.