bigbuffet-rw/app/soapbox/components/ui/form/form.tsx
2022-04-19 17:11:24 -05:00

24 lines
517 B
TypeScript

import * as React from 'react';
interface IForm {
onSubmit?: (event: React.FormEvent) => void,
className?: string,
}
const Form: React.FC<IForm> = ({ onSubmit, children, ...filteredProps }) => {
const handleSubmit = React.useCallback((event) => {
event.preventDefault();
if (onSubmit) {
onSubmit(event);
}
}, [onSubmit]);
return (
<form data-testid='form' onSubmit={handleSubmit} className='space-y-4' {...filteredProps}>
{children}
</form>
);
};
export default Form;