You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
649B

  1. import { Button } from '@mui/material';
  2. import { ReactNode } from 'react';
  3. // form
  4. import { FormProvider as Form, UseFormReturn } from 'react-hook-form';
  5. // ----------------------------------------------------------------------
  6. type Props = {
  7. children: ReactNode;
  8. methods: UseFormReturn<any>;
  9. onSubmit?: VoidFunction;
  10. };
  11. export default function FormProvider({ children, onSubmit, methods }: Props) {
  12. return (
  13. <Form {...methods}>
  14. <form onSubmit={onSubmit}>
  15. {children}
  16. {/* エンターでsubmitできるようにする */}
  17. <Button type="submit" sx={{ display: 'none' }} />
  18. </form>
  19. </Form>
  20. );
  21. }