Skip to content

Commit

Permalink
Update Form docs (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
coder054 authored and renatorib committed Mar 8, 2019
1 parent e316165 commit 3fabaa2
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions docs/components/Form.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,57 @@ name: Form
menu: 3. Form Containers
---

import { Props, Prop, ChildrenProps, ChildrenProp } from '../_ui/PropsTable'
import { Form } from '../../dist/react-powerplug.esm'

# Form

> This component has not yet been documented, if you wish to help us, click the "Edit Page"
> button above and help us create better documentation for react-powerplug!
The Form component is used for form with multiples fields and a submit handler

## Usage

```js
import { Form } from 'react-powerplug'
```

```jsx
<Form initial={{ firstName: '', lastName: '' }}>
{({ field, values }) => (
<form
onSubmit={e => {
e.preventDefault()
console.log('Form Submission Data:', values)
}}
>
<input
type="text"
placeholder="Your First Name"
{...field('firstName').bind}
/>
<input
type="text"
placeholder="Your Last Name"
{...field('lastName').bind}
/>
<input type="submit" value="All Done!" />
</form>
)}
</Form>
```

## Props

<Props>
<Prop name="initial" type="object" default={"{}"}>
Specifies the initial state for fields in the form (Object with keys is name of fields)
</Prop>
<Prop name="onChange" type="function">
The onChange event of the Value is called whenever the on state changes.
</Prop>
<Prop name="children" type="function">
Receive state as function. It can also be `render` prop.
</Prop>
</Props>

## Children Props

0 comments on commit 3fabaa2

Please sign in to comment.