キーワードstatic
と同じ理由です。これは、あなたのクラスを記述するのに役立つ、変化のない静的メタデータです。クラス(コンストラクターを呼び出さずにアクセス)をインスタンス化することなくアクセスできます。
class example extends Component {
static propTypes = {
something: PropTypes.object,
}
static displayName = "ExampleDisplay";
render() {
return <div />;
}
}
// I can access static properties here directly
var types = example.propTypes;
var name = example.displayName;
// I can NOT access the render method without instantiating the class.
var instance = new example(); // <- this calls the constructor and creates an instance.
var renderFn = instance.render;
質問は本当にです:私はpropTypesまたはdisplayNameを読み込むためだけにクラスを作成する必要がありますか?あなたはする必要はありません。だからあなたは静的なのです。