Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit cc3ac2e

Browse files
Upgrade to React 16 (#508)
1 parent 02b0469 commit cc3ac2e

12 files changed

+84
-808
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
name: Install dependencies (dash)
2828
command: |
2929
git clone [email protected]:plotly/dash.git
30-
git clone [email protected]:plotly/dash-renderer.git
30+
git clone -b react-16 [email protected]:plotly/dash-renderer.git
3131
git clone [email protected]:plotly/dash-html-components.git
3232
git clone [email protected]:plotly/dash-table.git
3333
. venv/bin/activate

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
66
### Added
77
- `extendData` prop for `Graph` component. This feeds `Plotly.extendTraces` for incremental data updates. [#461](https://github.com/plotly/dash-core-components/pull/461)
88

9+
### Changed
10+
[#508](https://github.com/plotly/dash-core-components/pull/508)
11+
- Upgrade from React 15.4.2 to 16.8.6
12+
- Upgrade from react-date 12.3.0 to 20.1.0
13+
914
### Fixed
1015
- Fix unnecessary `loading_state` prop for `Input` component. [#498](https://github.com/plotly/dash-core-components/issues/498)
1116
- Ensure `DatePickerSingle` callbacks fire with cleared dates. [#511](https://github.com/plotly/dash-core-components/pull/511)

dev-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
percy
22
selenium
33
pandas
4-
dash_table_experiments
54
xlrd
65
flake8

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"ramda": "^0.24.1",
4242
"rc-slider": "^8.3.1",
4343
"react-addons-shallow-compare": "^15.6.0",
44-
"react-dates": "^12.3.0",
44+
"react-dates": "^20.1.0",
4545
"react-docgen": "^2.21.0",
4646
"react-dropzone": "^4.1.2",
4747
"react-markdown": "^4.0.6",
@@ -70,17 +70,16 @@
7070
"jest": "^24.5.0",
7171
"npm-run-all": "^4.1.5",
7272
"prettier": "^1.14.2",
73-
"react": "^16.6.1",
74-
"react-dom": "^16.6.1",
75-
"react-dot-fragment": "^0.2.8",
73+
"react": "^16.8.6",
74+
"react-dom": "^16.8.6",
7675
"style-loader": "^0.23.1",
7776
"styled-jsx": "^3.1.1",
7877
"webpack": "^4.29.6",
7978
"webpack-cli": "^3.3.0",
8079
"webpack-serve": "^2.0.3"
8180
},
8281
"peerDependencies": {
83-
"react": "^15.6.0 || ^16.0.0",
84-
"react-dom": "^15.6.0 || ^16.0.0"
82+
"react": "^16.0.0",
83+
"react-dom": "^16.0.0"
8584
}
8685
}

src/components/DatePickerRange.react.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import 'react-dates/initialize';
12
import {DateRangePicker} from 'react-dates';
23
import PropTypes from 'prop-types';
3-
import R from 'ramda';
44
import React, {Component} from 'react';
55

66
import convertToMoment from '../utils/convertToMoment';
@@ -51,18 +51,19 @@ export default class DatePickerRange extends Component {
5151
}
5252
onDatesChange({startDate: start_date, endDate: end_date}) {
5353
const {setProps, updatemode} = this.props;
54+
5455
const old_start_date = this.state.start_date;
5556
const old_end_date = this.state.end_date;
56-
const newState = {};
57-
if (setProps && start_date !== null && start_date !== old_start_date) {
57+
58+
this.setState({start_date, end_date});
59+
60+
if (start_date && !start_date.isSame(old_start_date)) {
5861
if (updatemode === 'singledate') {
5962
setProps({start_date: start_date.format('YYYY-MM-DD')});
6063
}
6164
}
6265

63-
newState.start_date = start_date;
64-
65-
if (setProps && end_date !== null && end_date !== old_end_date) {
66+
if (end_date && !end_date.isSame(old_end_date)) {
6667
if (updatemode === 'singledate') {
6768
setProps({end_date: end_date.format('YYYY-MM-DD')});
6869
} else if (updatemode === 'bothdates') {
@@ -72,22 +73,14 @@ export default class DatePickerRange extends Component {
7273
});
7374
}
7475
}
75-
newState.end_date = end_date;
76-
77-
this.setState(newState);
7876
}
7977

8078
isOutsideRange(date) {
8179
const {min_date_allowed, max_date_allowed} = this.state;
82-
const notUndefined = R.complement(
83-
R.pipe(
84-
R.type,
85-
R.equals('Undefined')
86-
)
87-
);
80+
8881
return (
89-
(notUndefined(min_date_allowed) && date < min_date_allowed) ||
90-
(notUndefined(max_date_allowed) && date >= max_date_allowed)
82+
(min_date_allowed && date.isBefore(min_date_allowed)) ||
83+
(max_date_allowed && date.isAfter(max_date_allowed))
9184
);
9285
}
9386

@@ -121,6 +114,8 @@ export default class DatePickerRange extends Component {
121114
id,
122115
style,
123116
className,
117+
start_date_id,
118+
end_date_id,
124119
} = this.props;
125120

126121
const verticalFlag = calendar_orientation !== 'vertical';
@@ -178,6 +173,8 @@ export default class DatePickerRange extends Component {
178173
with_full_screen_portal && verticalFlag
179174
}
180175
withPortal={with_portal && verticalFlag}
176+
startDateId={start_date_id}
177+
endDateId={end_date_id}
181178
/>
182179
</div>
183180
);
@@ -194,6 +191,9 @@ DatePickerRange.propTypes = {
194191
*/
195192
start_date: PropTypes.string,
196193

194+
start_date_id: PropTypes.string,
195+
end_date_id: PropTypes.string,
196+
197197
/**
198198
* Specifies the ending date for the component.
199199
* Accepts datetime.datetime objects or strings

src/components/DatePickerSingle.react.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import 'react-dates/initialize';
2+
13
import {SingleDatePicker} from 'react-dates';
24
import moment from 'moment';
35
import PropTypes from 'prop-types';
4-
import R from 'ramda';
56
import React, {Component} from 'react';
67

78
import convertToMoment from '../utils/convertToMoment';
@@ -53,25 +54,18 @@ export default class DatePickerSingle extends Component {
5354

5455
isOutsideRange(date) {
5556
const {min_date_allowed, max_date_allowed} = this.state;
56-
const notUndefined = R.complement(
57-
R.pipe(
58-
R.type,
59-
R.equals('Undefined')
60-
)
61-
);
57+
6258
return (
63-
(notUndefined(min_date_allowed) && date < min_date_allowed) ||
64-
(notUndefined(max_date_allowed) && date >= max_date_allowed)
59+
(min_date_allowed && date.isBefore(min_date_allowed)) ||
60+
(max_date_allowed && date.isAfter(max_date_allowed))
6561
);
6662
}
6763

6864
onDateChange(date) {
6965
const {setProps} = this.props;
70-
if (setProps) {
71-
setProps({date: date ? date.format('YYYY-MM-DD') : null});
72-
} else {
73-
this.setState({date});
74-
}
66+
67+
this.setState({date});
68+
setProps({date: date ? date.format('YYYY-MM-DD') : null});
7569
}
7670

7771
render() {

src/components/Tab.react.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import React from 'react';
1+
import React, {Fragment} from 'react';
22
import PropTypes from 'prop-types';
3-
import Fragment from 'react-dot-fragment';
43

54
const Tab = ({children}) => <Fragment>{children}</Fragment>;
65

0 commit comments

Comments
 (0)