please write todo list code in react native using functional components
user
Sure, I can help you with that. Here's a simple example of a basic TODO list app in React Native using functional components:

1. First, you need to install the required dependencies:

   ```bash
   npm install react-native
   npm install @react-navigation/native
   npm install @react-navigation/stack
   ```

2. Create a new React Native project:

   ```bash
   npx react-native init MyTodoList
   ```

3. In your `index.js` file, import the necessary libraries and components:

   ```jsx
   import React from 'react';
   import { View, Text, FlatList, Button } from 'react-native';
   import { createStackNavigator } from '@react-navigation/stack';
   import AddTodoScreen from './AddTodoScreen';
   import { Ionicons } from '@expo/vector-icons';

   const Stack = createStackNavigator();

   function TodoScreen(props) {
     return (
       <View>
         <Text>Todo List</Text>
         <FlatList
           data={/* TODO: add your todo list data here */}
           renderItem={({ item }) => (
             <View>
               <Text>{item.title}</Text>
               <Button
                 title="Delete"
                 onPress={() => alert(`Deleted ${item.title}`)}
               />
             </View>
           )}
         />
       </View>
     );
   }

   function AddTodoScreen(props) {
     return (
       <View>
         <Text>Add TODO</Text>
       </View>
     );
   }

   function HomeScreen({ navigation }) {
     return (
       <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
         <Text>Welcome to MyTodoList</Text>
         <Button
           title="Go to Todo List"
           onPress={() => navigation.push('Todo')}
         />
         <Button
           title="Add Todo"
           onPress={() => navigation.push('AddTodo')}
         />
       </View>
     );
   }

   const StackNavigator = () => (
     <Stack.Navigator>
       <Stack.Screen
         name="Home"
         component={HomeScreen}
         options={{ title: 'MyTodoList' }}
       />
       <Stack.Screen name="Todo" component={TodoScreen} />
       <Stack.Screen name="AddTodo" component={AddTodoScreen} />
     </Stack.Navigator>
   );

   export default StackNavigator;
   ```

4. Run the application:

   ```bash
   npm start
   ```

5. Your app should be running on http://localhost:19006 or http://localhost:19007.

This is just a basic structure. You can implement your actual functionality in your `TodoScreen`, and provide an `onPress` handler for adding new todos in `HomeScreen`.
assistant
please write todo list code in react native using functional components
user
Sure, here's a simple example of a to-do list application using React Native with functional components and hooks:

```jsx
import React, { useState } from 'react';
import { View, TextInput, Button, FlatList, Text } from 'react-native';

const TodoList = () => {
  const [task, setTask] = useState('');
  const [tasks, setTasks] = useState([]);

  const handleAddTask = () => {
    setTasks([...tasks, task]);
    setTask('');
  };

  const handleRemoveTask = (index) => {
    const newTasks = [...tasks];
    newTasks.splice(index, 1);
    setTasks(newTasks);
  };

  return (
    <View>
      <TextInput
        value={task}
        onChangeText={setTask}
        placeholder="Enter a task"
      />
      <Button title="Add Task" onPress={handleAddTask} />
      <FlatList
        data={tasks}
        renderItem={({ item, index }) => (
          <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
            <Text>{item}</Text>
            <Button title="Delete" onPress={() => handleRemoveTask(index)} />
          </View>
        )}
        keyExtractor={(item, index) => index.toString()}
      />
    </View>
  );
};

export default TodoList;
```

This code creates a simple to-do list where you can add tasks and delete them. The `useState` hook is used to manage the state of the input field and the list of tasks. The `handleAddTask` function is used to add a new task to the list, and the `handleRemoveTask` function is used to remove a task from the list. The `FlatList` component is used to efficiently display the list of tasks.
assistant