score:27
typescript has no idea of the navigation type.
to just get rid of this error, you can type the navigation prop as any
(not advisable btw) like so:
/*doing this will make you lose type safety*/
const home = ({navigation}: {navigation: any}) => {
return ...
}
recommended approach
looking at the docs https://reactnavigation.org/docs/typescript/ we can see we need to create an object type with mappings for route name to the params of the route, then pass this object type as a generic to the createstacknavigator
function.
in the screens, we need to import the corresponding type from the navigator which in you case is the stacknavigator. this type takes 2 generics: a params list object type and the name of the current route.
// in your case
// app.tsx
import { createstacknavigator } from '@react-navigation/stack';
type rootstackparamlist = {
home: undefined, // undefined because you aren't passing any params to the home screen
profile: { name: string };
};
const stack = createstacknavigator<rootstackparamlist>();
// home.tsx
import { stacknavigationprop } from '@react-navigation/stack';
type profilescreennavigationprop = stacknavigationprop<
rootstackparamlist,
'home'
>;
type props = {
navigation: profilescreennavigationprop;
};
const home = ({navigation}: props) =>{
return ...
}
Source: stackoverflow.com
Related Query
- React navigation 5 error Binding element 'navigation' implicitly has an 'any' type.ts
- Graphql React Typescript error binding element 'currency' implicitly has an 'any' type
- react typescript error - element implicitly has an any type because expression of type string cant be used to index type {}
- binding element 'yyy' implicitly has an 'any' type error in typescript
- Binding element 'dispatch' implicitly has an 'any' type. var dispatch: any
- Ionic React - Binding element 'selected' implicitly has an 'any' type.ts(7031)
- React Typescript - Binding element 'C' implicitly has an 'any' type. TS7031
- React TypeScript: Parameter "e" implicitly has an any type error
- Getting type error of Binding element children implicitly of any
- Typescript react - Could not find a declaration file for module ''react-materialize'. 'path/to/module-name.js' implicitly has an any type
- How to fix Binding element 'children' implicitly has an 'any' type.ts(7031)?
- error TS2602: JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist
- Binding element 'Component' implicitly has an 'any' type.ts
- Binding element 'title' implicitly has an 'any' type
- Element type is invalid error using react-native and react navigation
- Element implicitly has an 'any' type because expression of type 'string' can't be used to index type React Typescript
- Binding element 'string' implicitly has an 'any' type
- Binding element 'x' implicitly has an 'any' type
- React Typescript: Element implicitly has an 'any' type because type has no index signature
- Using keyof in Typescript to get rid of 'element implicitly has any type' error
- Ionic ReactJS Binding element 'appProps' implicitly has an 'any' type. TS7031
- why typescript throws Binding element 'target' implicitly has an 'any' type.ts(7031)?
- Binding element 'posts' implicitly has an 'any' type
- React typescript error: Element implicitly has an 'any' type
- React: Binding element 'children' implicitly has an 'any' type
- Typescript with React > Element implicitly has an 'any' type because expression of type 'string' can't be used to index
- Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}' - React Anagram
- Binding element 'input' implicitly has an 'any' type in redux form
- error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index 'ModuleType'
- Element implicitly has an 'any'. typescript error
More Query from same tag
- React class method not defined no-undef
- Input Attribute onChange only if Props is not Undefined
- Different behavior after page is reloaded (app is in production mode, made by react and express)
- ReactJS onClick in list item chage div
- React-Stripe-Elements handleCardPayment with saved card
- React Recoil selector not triggering its get when the atom state updates to a previous value
- How to store images in Objects?
- React ant design drawer out side click disable
- clean urls with router.push in nextjs
- How do I smoothly transition fixed-size-div from one container to another on re-render?
- how to assign server response to object
- Can someone the differences between these two Express-React-Node application?
- Create React App PWA Push Notifications on Android
- Resetting formik forms after changing user
- TypeError: startDate.getTime is not a function
- Is it OK to put propTypes and defaultProps as static props inside React class?
- How testing my API calls in differents groups of test?
- No response even if img path is specified on React APP
- Invalid hook call. ReacJs
- redux form : Invalid prop `form` of type `object`
- Applying span on a string in react returns [object Object] instead of giving me the spanned text
- How to setInterval will disappear when at 0
- Axios is getting the data but I don't seem to be displaying it correctly on the front end
- Correct way (if possible) to store JSX code into a Javascript variable
- Component not re-rendering when nested observable changes
- React then returns cannot read property of undefined
- javascript setInterval paused when screen is locked (IOS)
- Error and no error with the same code: Failed to execute 'put' on 'IDBObjectStore'
- React-Intl Changing language does not change the translations
- Why is my React Color popup not updating?