Adding todo items
In the TodoApp
component, we'll add a text input that allows the user to enter new todo items. When they're done entering the todo, Relay will need to send a mutation to the backend GraphQL server. Here's what the component code looks like:
import React, { Component, PropTypes } from 'react'; import { View, TextInput, } from 'react-native'; import Relay from 'react-relay'; import styles from './styles'; import AddTodoMutation from './mutations/AddTodoMutation'; import TodoList from './TodoList'; export class TodoRelayMobile extends Component { static propTypes = { viewer: PropTypes.any.isRequired, relay: PropTypes.shape({ commitUpdate: PropTypes.func.isRequired, }), } // We need to keep track of new todo item text // as the user enters them. state = { text: '', } // When the user creates the todo by pressing enter, ...