mmazzarolo / react-native-modal-datetime-picker

A React-Native datetime-picker for Android and iOS
MIT License
2.96k stars 396 forks source link

Missing peerDependency on React #740

Open wojtekmaj opened 5 months ago

wojtekmaj commented 5 months ago

react-native-modal-datetime-picker fails to declare peerDependency on React (likely: >=17.0.0), which it imports in typings. Consequently, type checking react-native-modal-datetime-picker fails on Yarn in PnP mode (which is a bit more strict, not allowing packages access to other packages "by accident"):

Error: input_field/date_input.tsx(66,7): error TS2607: JSX element class does not support attributes because it does not have a 'props' property.
Error: input_field/date_input.tsx(66,[8]error TS2786: 'DateTimePicker' cannot be used as a JSX component.
  Its type 'typeof DateTimePicker' is not a valid JSX element type.
    Type 'typeof DateTimePicker' is not assignable to type 'new (props: any, deprecatedLegacyContext?: any) => Component<any, any, any>'.
      Type 'DateTimePicker' is missing the following properties from type 'Component<any, any, any>': context, setState, forceUpdate, render, and 3 more.

Adding the following to yarnrc.yml:

packageExtensions:
  react-native-modal-datetime-picker@17.0.0:
    peerDependencies:
      react: '>=17.0.0'

fixes the issue, which proves adding a peerDependency on react is all it takes to fix it.