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 ...

Get React and React Native now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.