O'Reilly logo

React and React Native by Adam Boduch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required