Typescript Error with React native Paper Components.
See original GitHub issueTO REPRODUCE: `// tsconfig file
{ “compilerOptions”: { “allowJs”: true, “allowSyntheticDefaultImports”: true, “esModuleInterop”: true, “isolatedModules”: true, “jsx”: “react”, “lib”: [“es6”], “moduleResolution”: “node”, “noEmit”: true, “strict”: true, “target”: “esnext” }, “exclude”: [ “node_modules”, “babel.config.js”, “metro.config.js”, “jest.config.js” ] }`
SAMPLE CODE: =
const StoreFront: React.FC = () => { return ( <ScrollView horizontal={true}> <Card key="key1"> <Card.Cover source={{ uri: "https://image" }} /> <Card.Actions> <Button>Cancel</Button> </Card.Actions> </Card> ))} </ScrollView> ); }; export default StoreFront;
TYPESCRIPT ERROR: = note😦 following error present on <Card >, <Button>,
etc components of react native paper.)
`(alias) const Card: (React.ComponentClass<Pick<Pick<ViewProps & React.RefAttributes<View> & {
children: React.ReactNode;
style?: StyleProp<ViewStyle>;
theme: Theme;
}, “style” | “children” | “ref” | “onLayout” | … 49 more … | “onTouchEndCapture”> & {
…;
} & {
…;
} & {
…;
}, “style” | … 55 more … | “elevation”> & {
…;
}, any> & hoistNonReactStatics.NonReactStatics<…>) | (React.FunctionComponent<…> & hoistNonReactStatics.NonReactStatics<…>)
import Card
Property ‘accessibilityStates’ is missing in type ‘{ children: Element[]; key: string; }’ but required in type ‘Pick<Pick<ViewProps & RefAttributes<View> & { children: ReactNode; style?: StyleProp<ViewStyle>; theme: Theme; }, “ref” | “style” | “removeClippedSubviews” | “hitSlop” | “onLayout” | … 48 more … | “accessibilityStates”> & { …; } & { …; } & { …; }, “ref” | … 55 more … | “elevation”>’.ts(2741) `
Issue Analytics
- State:
- Created 3 years ago
- Comments:28 (1 by maintainers)
Top GitHub Comments
@Nicwalle I fixed it temporarily with exact version of types. (It’s not a fix, but an acceptable solution while the issue #2442 is being solved. I will want to keep libs updating)
package.json
The easy fix is to install the version 0.62.2 or 0.62.2+ of @types/react-native package (the errors are removed in this version, 4-5 days ago)
npm i @types/react-native@0.62.2 --save-dev
Note: previously i had 0.62.12 installed