Relay.PropTypes

Relay 引入两个新类的对象:RelayContainer和Relay.Route。Relay.PropTypes 提供 props 验证, 用于断言 props 是这些类型。

概述 #

属性

示例 #

class MyApplication extends React.Component {
  static propTypes = {
    // Warns if `Component` is not a valid RelayContainer.
    Component: Relay.PropTypes.Container.isRequired,
    // Warns if `route` is not a valid route.
    route: Relay.PropTypes.QueryConfig.isRequired,
  };
  render() {
    return (
      <Relay.RootContainer
        Component={this.props.Component}
        route={this.props.route}
      />
    );
  }
}