FragmentContainer

FragmentContainer

The primary way to declare data requirements is via createFragmentContainer — a higher-order React component that lets React components encode their data requirements.

Similar to how a React component's render method does not directly modify native views, Relay containers do not directly fetch data. Instead, containers declare a specification of the data needed to render. Relay guarantees that this data is available before rendering.

A Complete Example

To start, let's build the plain React version of a <TodoItem> component that displays the text and completion status of a Todo.

Base React Component

Here's a basic implementation of <TodoItem> that ignores styling in order to highlight the functionality:

登录查看完整内容