react-native-paper: Typescript error: No overload matches this call.
I just init a expo typescript project. Then add ‘react-native-paper’ in my project. When try to use Button component it gives me this typescript error. Do you have any idea why getting error?
Error
No overload matches this call.
Overload 1 of 2, '(props: Pick<Props, "ref" | "style" | "children" | "hitSlop" | "onLayout" | "pointerEvents" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | ... 57 more ... | "contentStyle"> & { ...; }, context?: any): ReactElement<...> | ... 1 more ... | null', gave the following error.
Type '{ children: string; mode: "outlined"; onPress: () => void; }' is missing the following properties from type
Code -
<PaperProvider>
<View >
<Button mode="outlined" onPress={() => {}}>
press me
</Button>
</View>
</PaperProvider>
package.json
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"expo": "~40.0.0",
"expo-status-bar": "~1.0.3",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz",
"react-native-paper": "^4.5.0",
"react-native-web": "~0.13.12"
},
"devDependencies": {
"@babel/core": "~7.9.0",
"@types/react": "~16.9.35",
"@types/react-dom": "~16.9.8",
"@types/react-native": "~0.63.2",
"typescript": "~4.0.0"
},
"private": true
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 22
- Comments: 41 (1 by maintainers)
Links to this issue
Commits related to this issue
- chore(demo): remove extraneous accessibility props See https://github.com/callstack/react-native-paper/issues/2482 — committed to meliorence/react-native-render-html by jsamr 3 years ago
- chore(demo): revert @types/react-native to version 0.62.0 Waiting for upstream fix, see https://github.com/callstack/react-native-paper/issues/2482 — committed to meliorence/react-native-render-html by jsamr 3 years ago
- chore(demo): remove extraneous accessibility props See https://github.com/callstack/react-native-paper/issues/2482 — committed to meliorence/react-native-render-html by jsamr 3 years ago
- chore(demo): revert @types/react-native to version 0.62.0 Waiting for upstream fix, see https://github.com/callstack/react-native-paper/issues/2482 — committed to meliorence/react-native-render-html by jsamr 3 years ago
- chore(demo): remove extraneous accessibility props See https://github.com/callstack/react-native-paper/issues/2482 — committed to meliorence/react-native-render-html by jsamr 3 years ago
- chore(demo): revert @types/react-native to version 0.62.0 Waiting for upstream fix, see https://github.com/callstack/react-native-paper/issues/2482 — committed to meliorence/react-native-render-html by jsamr 3 years ago
- chore(demo): remove extraneous accessibility props See https://github.com/callstack/react-native-paper/issues/2482 — committed to robertwood-mobile/React-Native-Render-HTML by deleted user 3 years ago
- chore(demo): revert @types/react-native to version 0.62.0 Waiting for upstream fix, see https://github.com/callstack/react-native-paper/issues/2482 — committed to robertwood-mobile/React-Native-Render-HTML by deleted user 3 years ago
Working configuration right now:
There is one easy way to know what should be these versions.
Just pick version of
@types/react-native
from https://github.com/callstack/react-native-paper/blob/main/package.jsonHi got the solution. When initializing project using
expo init
it automatically added types for react-native project version@types/react-native@0.63.2
After upgrading the react-native type version to
@types/react-native@0.63.40
It is working fine.
I tried version 0.62.0 of
@types/react-native
and it didn’t work, i installed 0.63.0 and the errors disappearedsame for me…
ERROR No overload matches this call. Overload 1 of 2, ‘(props: Pick<Props, “ref” | “style” | “children” | “hitSlop” | “onLayout” | “pointerEvents” | “removeClippedSubviews” | “testID” | “nativeID” | “collapsable” | “needsOffscreenAlphaCompositing” | … 57 more … | “contentStyle”> & { …; }, context?: any): ReactElement<…> | … 1 more … | null’, gave the following error. Type ‘{ children: string; mode: “outlined”; onPress: () => void; }’ is missing the following properties from type ‘Pick<Props, “ref” | “style” | “children” | “hitSlop” | “onLayout” | “pointerEvents” | “removeClippedSubviews” | “testID” | “nativeID” | “collapsable” | “needsOffscreenAlphaCompositing” | … 57 more … | “contentStyle”>’: accessibilityComponentType, accessibilityTraits Overload 2 of 2, ‘(props: PropsWithChildren<Pick<Props, “ref” | “style” | “children” | “hitSlop” | “onLayout” | “pointerEvents” | “removeClippedSubviews” | “testID” | “nativeID” | “collapsable” | “needsOffscreenAlphaCompositing” | … 57 more … | “contentStyle”> & { …; }>, context?: any): ReactElement<…> | … 1 more … | null’, gave the following error. Type ‘{ children: string; mode: “outlined”; onPress: () => void; }’ is missing the following pr
PACKEGE
“dependencies”: { “@babel/plugin-proposal-decorators”: “^7.12.12”, “babel-plugin-transform-decorators-legacy”: “^1.3.5”, “mobx”: “^6.0.5”, “mobx-react”: “^7.0.6”, “react”: “16.13.1”, “react-native”: “0.63.4”, “react-native-paper”: “^4.7.1”, “react-native-vector-icons”: “^8.0.0” }, “devDependencies”: { “@babel/core”: “^7.8.4”, “@babel/runtime”: “^7.8.4”, “@react-native-community/eslint-config”: “^1.1.0”, “@types/color”: “^3.0.1”, “@types/jest”: “^25.2.3”, “@types/react-native”: “^0.63.46”, “@types/react-test-renderer”: “^16.9.2”, “babel-jest”: “^25.1.0”, “eslint”: “^6.5.1”, “jest”: “^25.1.0”, “metro-react-native-babel-preset”: “^0.59.0”, “react-test-renderer”: “16.13.1”, “typescript”: “^3.8.3” },
this issue is also present for me with many attempts over the last few days trying to figure out which
@types/react-native
version is causing this leading to nowherecreating a new TS project with expo init and following RN paper instructions for installing the library should recreate the issue.
I’m currently facing this issue when trying to import the Text component😕
Error :
Package.json:
To all strugling with react native paper lint errors Simply search in the package.json of react native paper : https://github.com/callstack/react-native-paper/blob/main/package.json, (change the tag with the version of react native paper you use) And change the react-native and @types/react-native version to the same as in the package.json of react native paper
I just ran this command and everything works fine:
yarn add -D @types/react-native
Working with Expo SDK 43 (react-native 0.64.3 - @types/react-native 0.64.19) and react-native-paper 4.9.2
I did:
npm i react-native@latest npm i react-native-paper@latest npm i --save-dev @types/react-native@latest
and it didn’t workIf we can just @latest all the associated packages then I would think this can be closed.
It seems this PR once closed will fix problem #2522
Issue is back for me as well. Currently on @types/react-native 0.63.46.
I was able to fix this by only upgrading my
@types/react-native
to the latest version (0.66.15 at time of writing this).yarn add -D @types/react-native@latest
My relevant dependencies prior to upgrading were as follows:
Yes, same here. This seems very annoying due to our tooling failing
Problem fix do not use a title or any kind of attr for button because btn dont have like this attr.
This issue is back for me with the most recent version of @types/react-native (@0.63.45 for @latest at time of writing this)