Skip to content

Issues with Typescript + React native #86

Description

@rafaelcorreiapoli

Are you submitting a bug report or a feature request?

Feature request

What is the current behavior?

Type errors with react-native + typescript

What is the expected behavior?

No type errors :P

What's your environment?

I'm using react-final-form with react-native

"react-final-form": "^2.1.1",
"final-form": "^3.0.0",
"react": "16.0.0",
"react-native": "0.50.4",

Other information

There are two situations where I have type errors.

1. handleSubmit

The current type for handleSubmit is:

handleSubmit: (event: React.SyntheticEvent<HTMLFormElement>) => void

How can we deal with this in react-native?
onPress events of touchables have this signature:

onPress?: (event: GestureResponderEvent) => void;

2. Field extra props

Sometimes we need to pass some extra props to the underlying component of Field

            <Field
              name='firstName'
              component={TextInputField}
              style={styles.textInputStyle}
            />

In this case, the style prop is the extra one.
The type system complains because the props that Field is expecting are:

export type FieldProps = {
  allowNull?: boolean
  format?: ((value: any, name: string) => any) | null
  parse?: ((value: any, name: string) => any) | null
  name: string
  subscription?: FieldSubscription
  validate?: (value: any, allValues: object) => any
  value?: any
} & RenderableProps<FieldRenderProps>

Maybe we should allow anything here? :\ 👎

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions