secullum-react-native-ui 4.16.2-beta.6 → 4.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,26 @@ const layout_1 = require("../modules/layout");
11
11
  require("react-date-range/dist/styles.css");
12
12
  const react_native_1 = require("react-native");
13
13
  require("../../styles/RangeDatePicker.css");
14
- class PureDateRange extends React.PureComponent {
14
+ function compareDates(date1, date2) {
15
+ if (date1 instanceof Date && date2 instanceof Date) {
16
+ return date1.getTime() === date2.getTime();
17
+ }
18
+ return date1 === date2;
19
+ }
20
+ class PureDateRange extends React.Component {
21
+ // Without this check, every time the parent re-renders it would
22
+ // recreate the DateRange with the initial startDate value,
23
+ // even if the date hasn't actually changed.
24
+ // This causes the calendar to reset and the user loses the current
25
+ // selection while interacting.
26
+ // Related issue on GitLab 12293
27
+ shouldComponentUpdate(nextProps) {
28
+ if (nextProps.onChange !== this.props.onChange) {
29
+ return true;
30
+ }
31
+ return (!compareDates(nextProps.startDate, this.props.startDate) ||
32
+ !compareDates(nextProps.endDate, this.props.endDate));
33
+ }
15
34
  render() {
16
35
  const { startDate, endDate, onChange } = this.props;
17
36
  const theme = (0, theme_1.getTheme)();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "secullum-react-native-ui",
3
- "version": "4.16.2-beta.6",
3
+ "version": "4.16.2",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "files": [