Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create FormModal component to clean up modal code #61

Open
cory2067 opened this issue Mar 5, 2022 · 0 comments
Open

Create FormModal component to clean up modal code #61

cory2067 opened this issue Mar 5, 2022 · 0 comments
Assignees
Labels
refactor Cleaning up technical debt, etc

Comments

@cory2067
Copy link
Owner

cory2067 commented Mar 5, 2022

One common pattern in this repo is having a form inside a modal.

Something vaguely like this to give an idea of what I mean:

function FormModal(props) { // todo flesh out these props
  const [formData, setFormData] = useState(props.initialFormData);
  const onValuesChange = (newData) => setFormData({...formData, ...newData});
  return (
    <Modal
       ...props,
       onOk={() => props.handleOk(formData)}
    >
        <Form onValuesChange={onValuesChange} initialValues={props.initialFormData}
          { props.formContents}
       </Form>
    </Modal>
  )
}

This can help reduce some of the boilerplate involved in setting up form modals

@cory2067 cory2067 added the refactor Cleaning up technical debt, etc label Mar 5, 2022
@cory2067 cory2067 self-assigned this Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Cleaning up technical debt, etc
Projects
None yet
Development

No branches or pull requests

1 participant