reactjsstandardjs

StandardJS and React class export Unexpected token =


Can anyone shed some light on the notice I am getting back from StandardJS?

Parsing error: Unexpected token =

Code is as follows:

export default class foreignDataFormat extends _base {
    static input = class ForeignDataFormatInput extends React.Component {
        render () {

        }
    }
}

The error is referring to the second line input = class


Solution

  • In JavaScript, class cannot be defined as static. But method can be defined as static. You would just define (and probably mean to define) the class like:

    export default class foreignDataFormat extends _base {
        const input = class ForeignDataFormatInput extends React.Component {
            static myMethod() { 
              //... my static method
            }
            render () {
    
            }
        }
    }
    

    You may be interested to see this post.