import React from 'react'; import { View, Text, Switch, TouchableOpacity } from 'react-native'; import { useForm, Controller } from 'react-hook-form'; import { z } from 'zod'; import { zodResolver } from '@hookform/resolvers/zod'; const items = [ { id: 'recents', label: 'Recents' }, { id: 'home', label: 'Home' }, { id: 'applications', label: 'Applications' }, { id: 'desktop', label: 'Desktop' }, { id: 'downloads', label: 'Downloads' }, { id: 'documents', label: 'Documents' }, ]; const displayFormSchema = z.object({ items: z.array(z.string()).refine((value) => value.some((item) => item), { message: "You have to select at least one item.", }), }); type DisplayFormValues = z.infer; const defaultValues: Partial = { items: ['recents', 'home'], }; export function DisplayForm() { const { control, handleSubmit } = useForm({ resolver: zodResolver(displayFormSchema), defaultValues, }); const onSubmit = (data: DisplayFormValues) => { console.log(JSON.stringify(data, null, 2)); }; return ( Sidebar Select the items you want to display in the sidebar. {items.map((item) => ( ( { const updatedValue = checked ? [...field.value, item.id] : field.value?.filter((value) => value !== item.id); field.onChange(updatedValue); }} /> {item.label} )} /> ))} Update display ); }