API Cheatsheet

API Cheatsheet

A reference for translating between the Relay Classic and Relay Modern APIs.

To add a new root for relay components

Classic: <RelayRootContainer>

Modern: <QueryRenderer>

To add a new relay container

Classic: Relay.createContainer

Modern: createFragmentContainer

To add a new relay container that has changing data requirements

Classic: Relay.createContainer

Modern createRefetchContainer

To add a new paginating relay container

Classic: Relay.createContainer

Modern: createPaginationContainer

To update a variable for my component

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

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

To paginate through a connection

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

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

To force fetch a component

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

To commit a mutation

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

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

© 2013–present Facebook Inc.
Licensed under the BSD License.
https://facebook.github.io/relay/docs/api-cheatsheet.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部