import * as React from "react"; import { useDialogState, Dialog, DialogDisclosure } from "reakit/Dialog"; import { unstable_useFormState as useFormState, unstable_Form as Form, unstable_FormLabel as FormLabel, unstable_FormInput as FormInput, unstable_FormMessage as FormMessage, unstable_FormSubmitButton as FormSubmitButton, } from "reakit/Form"; type Props = { initialName: string; onRename: (newName: string) => void; }; function RenameForm({ initialName = "", onRename }: Props) { const form = useFormState({ values: { name: initialName }, onValidate: (values) => { if (!values.name) { const errors = { name: "You must provide a name!", }; throw errors; } }, onSubmit: (values) => onRename(values.name), }); return (
); } export default function DialogWithForm() { const [name, setName] = React.useState("Name"); const dialog = useDialogState(); return ( <> {name}