Skip to content

Commit

Permalink
Merge pull request #4 from studio-206/feat/pass-props-from-component
Browse files Browse the repository at this point in the history
update form tsx
  • Loading branch information
karltaylor authored Dec 2, 2022
2 parents b2ff8b8 + 97558a3 commit 535beeb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@studio206/react-toolkit",
"version": "1.2.1",
"version": "1.2.2",
"main": "dist/index.js",
"files": [
"dist"
Expand Down
12 changes: 8 additions & 4 deletions src/components/Form.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import React, { FormEvent } from "react";
import React, { FormEvent, HTMLProps } from "react";

interface FormProps {
interface FormProps extends HTMLProps<HTMLFormElement> {
children: React.ReactNode;
onSubmit: (event: FormEvent<HTMLFormElement>) => void;
}

const Form = ({ children, onSubmit }: FormProps) => {
const Form = ({ children, onSubmit, ...props }: FormProps) => {
const handleSubmit = (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
onSubmit(e);
};

return <form onSubmit={handleSubmit}>{children}</form>;
return (
<form onSubmit={handleSubmit} {...props}>
{children}
</form>
);
};

export default Form;

0 comments on commit 535beeb

Please sign in to comment.