facebook / prop-types

Runtime type checking for React props and similar objects
MIT License
4.48k stars 356 forks source link

react navigtion props type : PropType is defined but prop is never used #317

Closed khaledBou closed 4 years ago

khaledBou commented 4 years ago

I can't validate tab navigator prop type :

function ButtomTabs() {
  return (
    <Tab.Navigator
      initialRouteName="Home"
      activeColor={COLORS.ACTIVETAB}
      inactiveColor={COLORS.INACTIVETAB}
      barStyle={{backgroundColor: COLORS.DEFAULT}}
      backBehavior="initialRoute"
      lazy
      shifting={false}
      tabBarOptions={{
        activeTintColor: COLORS.ACTIVETAB,
        inactiveTintColor: COLORS.INACTIVETAB,
      }}>
      <Tab.Screen
        name="Home"
        component={HomeStackScreen}
        options={{
          tabBarLabel: 'Accueil',
          tabBarColor: COLORS.DEFAULT,
          tabBarIcon: ({color}) => <MaterialCommunityIcons name="home" color={color} size={26} />,
        }}
      />
ButtomTabs.propTypes = {
  // Un objet avec une forme spécifique
  tabBarOptions: PropTypes.shape({
    activeTintColor: PropTypes.string,
  }).isRequired,
};

ButtomTabs.propTypes = {
  color: PropTypes.string.isRequired,
};

I got always : 'color' PropType is defined but prop is never used

ljharb commented 4 years ago

This seems like an eslint error, which means it should be filed on eslint-plugin-react and not on prop-types.

However, in your example, you don't use any props - tabBarIcon is a render prop which doesn't have anything to do with the props of the ButtomTabs component (which in your case would be passed as an argument at the top of that function; but it currently takes no arguments).