Skip to content

Commit b60f7ab

Browse files
Lleioserikras
authored andcommitted
Enhanced type definition (#18)
* Add definition Definition based on react-final-form * Revert "handle onChange without event" This reverts commit c323b32. * Unsubscrite on component unmount * Add type parameter to useField
1 parent 6364d38 commit b60f7ab

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/index.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ type NonFunctionPropertyNames<T> = {
2424
}[keyof T]
2525
type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>
2626

27-
export interface FieldRenderProps {
27+
export interface FieldRenderProps<V = any> {
2828
input: {
2929
name: string
3030
onBlur: <T>(event?: React.FocusEvent<T>) => void
31-
onChange: <T>(event: React.ChangeEvent<T> | any) => void
31+
onChange: <T>(event: React.ChangeEvent<T> | V) => void
3232
onFocus: <T>(event?: React.FocusEvent<T>) => void
33-
value: any
33+
value: V
3434
checked?: boolean
3535
}
3636
meta: NonFunctionProperties<FieldState>
@@ -47,9 +47,9 @@ declare module 'react-final-form-hooks' {
4747
subscription?: FormSubscription
4848
): FormRenderProps
4949

50-
export function useField(
50+
export function useField<V = any>(
5151
name: string,
5252
form: FormApi,
5353
subscription?: FieldSubscription
54-
): FieldRenderProps
54+
): FieldRenderProps<V>
5555
}

0 commit comments

Comments
 (0)