javascript - Pass default parameter values in function react - Stack Overflow

I got this error after updating react-native and reactI think this is right syntax, but I don't kn

I got this error after updating react-native and react

I think this is right syntax, but I don't know why this error is shown:

 this.list = function(table, callback, wheredata = [],selection = '',extra = '') {

SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._pile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object. (/Users/apcrat/Documents/redux/delfoo_React/api/model/catalog/cuisine_route.js:7:12)
at Module._pile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)

I got this error after updating react-native and react

I think this is right syntax, but I don't know why this error is shown:

 this.list = function(table, callback, wheredata = [],selection = '',extra = '') {

SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._pile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object. (/Users/apcrat/Documents/redux/delfoo_React/api/model/catalog/cuisine_route.js:7:12)
at Module._pile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)

Share Improve this question edited Oct 1, 2016 at 20:21 marc_s 756k184 gold badges1.4k silver badges1.5k bronze badges asked Aug 8, 2016 at 11:58 Nilay BrahmbhattNilay Brahmbhatt 131 gold badge1 silver badge7 bronze badges 3
  • may be something wrong with this.list = ? – Ivan Chernykh Commented Aug 8, 2016 at 12:00
  • You are going to need to give more context.. Are you using that in a class? – Nicholas Robinson Commented Aug 8, 2016 at 12:05
  • 1 you cannot set default value for argument in Ecmascript 5. you can set wheredata = wheredata || []; inside your function – Olivier Boissé Commented Aug 8, 2016 at 12:18
Add a ment  | 

1 Answer 1

Reset to default 2

You need to pile your code with Babel.js to use Ecmascript 6 features or if you want to work on es5, you can do like this

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744388448a4571783.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信