had same problem, for me the slution was that I forgot to close a '}'.


Try using this.state in your constructor of class component in react.js file. Assign a property to this.statement and it will not give you any error. For example:

class App extends React.Component {
    this.state= {
         anyProperty : itsValue;



In your SignInScreen.js file do:

export const ACCESS_TOKEN = "token";

In your other js file you want to use it you will have to do something like this:

import * as globalConst from 'path/to/SignInScreen';

var token = globalConst.ACCESS_TOKEN;

Hope this helps.


The const is inside a class, move it outside of the class and the error will disappear.


This error occurs when you use const, let, var keywords inside a class in javascript. To set a property to a class, you do not use const, let or var keywords.

But you need to use const, var or let keywords to define variables inside a method of a class example

class List extends React.Component{
     // But using const outside method and inside a class will give error
     /* const accessToken = ACCESS_TOKEN  is wrong syntax */
   render() {
     const accessToken = ACCESS_TOKEN;   // will not give error



The const is inside a class. Move it outside the class and all will be ok.

Related Query

More Query from same tag