stephy / CalendarPicker

CalendarPicker Component for React Native
787 stars 369 forks source link

Does not render minDate and maxDate change #272

Closed serkanekinci closed 3 years ago

serkanekinci commented 3 years ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch react-native-calendar-picker@7.0.9 for the project I'm working on because [Insert reason here].

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-calendar-picker/CalendarPicker/index.js b/node_modules/react-native-calendar-picker/CalendarPicker/index.js
index c225330..c1dfb73 100644
--- a/node_modules/react-native-calendar-picker/CalendarPicker/index.js
+++ b/node_modules/react-native-calendar-picker/CalendarPicker/index.js
@@ -74,9 +74,7 @@ export default class CalendarPicker extends Component {

     let minMaxDates = {};
-    if (prevProps.minDate !== this.props.minDate ||
-        prevProps.minDate !== this.props.minDate
-    ) {
+    if (prevProps.minDate !== this.props.minDate || prevProps.maxDate !== this.props.maxDate) {
       minMaxDates.minDate = this.props.minDate && moment(this.props.minDate);
       minMaxDates.maxDate = this.props.maxDate && moment(this.props.maxDate);
+
+      doStateUpdate = true
     }

This issue body was partially generated by patch-package.

peacechen commented 3 years ago

Thanks @serkanekinci for finding this bug. Please submit a PR.

peacechen commented 3 years ago

Published in 7.1.1.

To speed up fixes in the future, please submit a PR instead of a patch file.