react-native-calendars: ExpandableCalendar error under React native 0.74

today i upgraded my app to react native 0.74 and i got the following error:

ERROR Warning: ExpandableCalendar: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.

This warning message indicates that your code is using a deprecated way of setting default values for props in React functional components

### Tasks
### Tasks

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 10
  • Comments: 26

Most upvoted comments

diff --git a/node_modules/react-native-calendars/src/expandableCalendar/index.js b/node_modules/react-native-calendars/src/expandableCalendar/index.js
index 4fb12b0..cfaad3f 100644
--- a/node_modules/react-native-calendars/src/expandableCalendar/index.js
+++ b/node_modules/react-native-calendars/src/expandableCalendar/index.js
@@ -409,15 +409,4 @@ const ExpandableCalendar = (props) => {
 };
 export default ExpandableCalendar;
 ExpandableCalendar.displayName = 'ExpandableCalendar';
-ExpandableCalendar.defaultProps = {
-    horizontal: true,
-    initialPosition: Positions.CLOSED,
-    firstDay: 0,
-    leftArrowImageSource: LEFT_ARROW,
-    rightArrowImageSource: RIGHT_ARROW,
-    allowShadow: true,
-    openThreshold: PAN_GESTURE_THRESHOLD,
-    closeThreshold: PAN_GESTURE_THRESHOLD,
-    closeOnDayPress: true
-};
 ExpandableCalendar.positions = Positions;

@zkteco-home , same error message, so the error is in defaultProps in ExpandableCalendar? since there is no new commit, how to avoid the error message locally? thanks!

As @debugtheworldbot suggested a simple temporary fix. I would also recommend the same fix until devs patch the issues with an update. Till then this is the fix:

ExpandableCalendar.defaultProps = undefined;

For TypeScript: (ExpandableCalendar as any).defaultProps = undefined;

This should temporarily fix the issues till a patch or an update arrives.

Maybe someone doesn’t want add a patch for this. I just add a simple temporary fix to avoid this warning:

// @ts-ignore fix for defaultProps warning: https://github.com/wix/react-native-calendars/issues/2455
ExpandableCalendar.defaultProps = undefined