0

So i am using react-navigation in my react-native project with typescript and redux but when i an setting a the contentComponent prop for the drawerNavigator i am getting this error in typescript.

Type 'ConnectedComponentClass<SomeClass>' is not assignable to type 'ComponentType<DrawerItemsProps>' Type 'SomeClass' is missing the following properties from type 'DrawerItemsProps': navigation, items, getLabel, renderIcon, and 2 more..

Is there any workaround for the same.

Any help on the same would be highly appreciated.

Amol Gupta
  • 2,054
  • 1
  • 14
  • 29

1 Answers1

0

It seems that the type DrawerItemsProps has properties like navigation, items, getLabel, renderIcon and more and these are missing in your SomeClass interface.

So you can make all these properties which are missing as optional using '?' like below

interface DrawerItemsProps {
  // other properties
  navigation?: yourType,
  items?: yourType, 
  getLabel?: yourType,
  renderIcon?: yourType
}
dileepkumar jami
  • 2,185
  • 12
  • 15
  • nope i don't think thats the correct way of doing this, One needs to use one of type definitions provided by react-navigation in class props, this seems more like an ad-hoc solution. – Amol Gupta Feb 08 '19 at 06:04
  • @AmolGupta, Yes, I answered as you asked for a workaround – dileepkumar jami Feb 08 '19 at 06:24
  • 1
    So react navigation exports a DrawerItemProps from react-navigation types I extended the class interface with the same and it work now. Thank you for all the help by the way. – Amol Gupta Feb 08 '19 at 06:27