Skip to content

Commit

Permalink
Fix type of Redux Form event handlers. (#31607)
Browse files Browse the repository at this point in the history
* Fix type of Redux Form event handlers.

* Rename `fieldName` to `name` to keep flow type definitions consistent with Redux Form naming.

Co-Authored-By: davidgomes <davidrafagomes@gmail.com>

* Adds the missing name parameter to the onFocus and onDragStart event handlers in redux-form.

https://redux-form.com/7.4.2/docs/api/field.md/#-code-onblur-event-newvalue-previousvalue-name-gt-void-code-optional-

https://redux-form.com/7.4.2/docs/api/field.md/#-code-ondragstart-event-name-gt-void-code-optional-

Co-Authored-By: davidgomes <davidrafagomes@gmail.com>

* Removes weird space I added accidentally.
  • Loading branch information
davidgomes authored and sheetalkamat committed Dec 31, 2018
1 parent 2d5bc81 commit 6b9f1df
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions types/redux-form/lib/Field.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export type Formatter = (value: any, name: string) => any;
export type Parser = (value: any, name: string) => any;
export type Validator = (value: any, allValues?: any, props?: any, name?: any) => any;

export type EventHandler<Event> = (event: Event) => void;
export type EventWithDataHandler<Event> = (event?: Event, newValue?: any, previousValue?: any) => void;
export type EventHandler<Event> = (event: Event, name?: string) => void;
export type EventWithDataHandler<Event> = (event?: Event, newValue?: any, previousValue?: any, name?: string) => void;

export interface EventOrValueHandler<Event> extends EventHandler<Event> {
(value: any): void;
Expand Down
4 changes: 2 additions & 2 deletions types/redux-form/redux-form-tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ const Test = reduxForm<TestFormData>({
<Field
name="field4"
component="input"
onChange={(event, newValue, previousValue) => {}}
onBlur={(event, newValue, previousValue) => {}}
onChange={(event, newValue, previousValue, fieldName) => {}}
onBlur={(event, newValue, previousValue, fieldName) => {}}
/>

<ImmutableField
Expand Down

0 comments on commit 6b9f1df

Please sign in to comment.