question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues with Typescript + React native

See original GitHub issue

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 😛

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? :\ 👎

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
rafaelcorreiapolicommented, Dec 31, 2017

styled-components is a library compatible with both react and react-native (and it has completely different implementations for each one). The way it’s API works is by exposing functions from styled-components/native. So if you are targeting web you import from styled-components and if you are targeting react-native, you import from styled-components/native. Maybe we could expose a different component (under react-form-react/native) for react-native usage

2reactions
sergei-zelinskycommented, Mar 26, 2019

Hello there!

Are there any updates on this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using TypeScript - React Native
TypeScript is a language which extends JavaScript by adding type definitions, much like Flow. ... To fix the issue try uninstalling the CLI:....
Read more >
Issues · react-native-community/react-native-template-typescript
Issues list ; Android and iOS folders are missing while executing the command. #312 opened on Nov 7 ; set 'no-unused-vars' prop value...
Read more >
Should You Use TypeScript with React Native? [2021]
Pros of TypeScript in React Native · Self documenting - By writing types you're documenting what values you expect in a function/component.
Read more >
React native typescript issue - Stack Overflow
When I create a react native app from the command line using create-react-native-app <project_name>, it gets configured in typescript format ...
Read more >
Should we use TypeScript with React Native ? - GeeksforGeeks
Should we use TypeScript with React Native ? · More dependencies need to be managed : You have to add types for each...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found