Skip to content

Commit

Permalink
Added dispatch to props for Field (#1569)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikras committed Aug 19, 2016
1 parent a5b665f commit 931d801
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/api/Field.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ input element.

> `true` if the field value has changed from its initialized value. Opposite of `pristine`.
#### `meta.dispatch : Function`

> The Redux `dispatch` function.
#### `meta.error : String` [optional]

> The error for this field if its value is not passing validation. Both synchronous,
Expand Down
7 changes: 7 additions & 0 deletions src/__tests__/Field.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ const describeField = (name, structure, combineReducers, expect) => {
expect(props.meta.error).toBe('foo error')
})

it('should provide meta.dispatch', () => {
const props = testProps({})
expect(props.meta.dispatch)
.toExist()
.toBeA('function')
})

it('should provide name getter', () => {
const store = makeStore({
testForm: {
Expand Down
1 change: 1 addition & 0 deletions src/createFieldProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const createFieldProps = (getIn, name,
active: state && !!getIn(state, 'active'),
asyncValidating,
dirty,
dispatch,
error,
invalid: !!error,
pristine,
Expand Down

0 comments on commit 931d801

Please sign in to comment.