API 手册

Relay Classic 和 Relay Modern API 之间的转换参考。

为relay 组件添加权限 #

Classic: <RelayRootContainer>

Modern: <QueryRenderer>

添加新的 Relay 容器 #

Classic: Relay.createContainer

Modern: createFragmentContainer

添加一个新的具有变化的数据需求的 Relay 容器。#

Classic: Relay.createContainer

Modern createRefetchContainer

添加新的分页 Relay 容器 #

Classic: Relay.createContainer

Modern: createPaginationContainer

为自定义组件更新变量 #

Classic: this.props.relay.setVariable({foo: bar}...)

Modern: this.props.relay.refetch({foo: bar}... in a Refetch Container

通过连接分页#

Classic: this.props.relay.setVariable({count: prevCount + pageSize}...)

Modern this.props.relay.loadMore(pageSize...) in a Pagination Container

强制获取组件 #

Classic: this.props.relay.forceFetch()

Modern: this.props.relay.refetchConnection(...) in a Pagination Container

or: this.props.relay.refetch({}, {}, callback, {force: true}) in a Refetch Container

提交 mutation #

Classic: this.props.relay.commitUpdate(mutation...)

Modern: commitMutation(this.props.relay.environment, {mutation...})