How do you declare "const" in native-native?

I keep getting the error SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode.

I think it is because I have a line like this:

    const shouldSet = touches.length === 1;
    if (shouldSet) {
      const { onPanBegin } = this.props;

      

+3


source to share


3 answers


Update 2015-10-23 : from React Native v0.13.0-rc is const

now included .

React Native JavaScript environment is not a browser, it uses JavaScriptCore instead . Anything not natively supported must be converted to a subset of JS supported by JavaScriptCore, and React Native uses Babel to do this.Here are the conversions that React Native uses (as of 2015-07-31):

ES5

  • Reserved words: prom.catch (function () {});

ES6



  • Arrow functions
  • Call distribution
  • Classes
  • destructive
  • Computed properties
  • Object Consolidated method
  • Concise object notation
  • Rest params
  • Template literals:

ES7

  • Propagating objects
  • Trailing Comma function

It's not immediately clear to me why constants are not included in this list, and it seems that support for overriding it is not quite ready yet:

https://github.com/facebook/react-native/issues/1451

+3


source


The keyword is const

not currently supported in android action-native, I hope it will be available with the next version of action-native. The fix was trivial, for more details on the origins of the github issue .



0


source


you need to get the latest react-native.

pod 'React', '0.13.0-rc'

0


source







All Articles