Issues with Typescript + React native
See original GitHub issueAre 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:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 fromstyled-components
and if you are targeting react-native, you import fromstyled-components/native
. Maybe we could expose a different component (underreact-form-react/native
) for react-native usageHello there!
Are there any updates on this issue?