S
S
Stepan2015-09-13 18:10:11
JavaScript
Stepan, 2015-09-13 18:10:11

How and where in ES6 will it be correct to put propTypes?

propTypes: {
        data: React.PropTypes.object.isRequired
    },

static doesn't work. I can't make changes to the project at the dependency update level

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Petrov, 2015-09-13
@xoma2

class SomeComponent extends React.Component {
    ...
}

SomeComponent.propTypes = {
  data: React.PropTypes.object.isRequired
}

S
Sergey, 2015-09-13
Protko @Fesor

class SomeComponent extends React.Component {
    get propTypes() {
         return {
             data: React.PropTypes.object.isRequired
         };
    }
}

D
DenniLa2, 2017-03-18
@DenniLa2

class SomeComponent extends React.Component {
  static propTypes = {
    data: React.PropTypes.object.isRequired
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question