nusaxe
nusaxe

Reputation: 1

Attempting to compile this code simply wont work. Getting a parsing error from react.js and vscode

Here is the code:

  const shape = {
  id: Prop.Type.string.isRequired,
  message: Prop.Type.node.isRequired,
  link: Prop.Type.string,
  options:Prop.Type.arrayOf(
    Prop.Type.shape(NestedDropdown.shape)
  )
};

And a screenshot

Screenshot

Upvotes: 0

Views: 36

Answers (1)

danielhep
danielhep

Reputation: 356

You can't use "const" when defining a field inside a class.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes

Fields are defined like this:

class Rectangle {
  height = 0;
  width;
}

There is some discussion of how to create constants in this thread: Declaring static constants in ES6 classes?

Upvotes: 2

Related Questions