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

Upgrade to React 16 #508

Merged
merged 22 commits into from
Apr 9, 2019
Merged

Upgrade to React 16 #508

merged 22 commits into from
Apr 9, 2019

Conversation

Marc-Andre-Rivet
Copy link
Contributor

@Marc-Andre-Rivet Marc-Andre-Rivet commented Apr 3, 2019

Fixes #428
Fixes https://github.com/plotly/dash-core/issues/13

main pr, renderer: plotly/dash-renderer#145

  • Remove dash_table_experiment and replace by dash_table
  • DatePickerSingle & Range issues with React 16

@@ -27,7 +27,7 @@ jobs:
name: Install dependencies (dash)
command: |
git clone [email protected]:plotly/dash.git
git clone [email protected]:plotly/dash-renderer.git
git clone -b react-16 [email protected]:plotly/dash-renderer.git
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be removed once merged into master

@@ -1,6 +1,5 @@
import React from 'react';
import React, {Fragment} from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fragment is supported by React 16, remove the polyfill

"react-dom": "^16.6.1",
"react-dot-fragment": "^0.2.8",
"react": "^16.8.6",
"react-dom": "^16.8.6",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump react, remove polyfill

@@ -1,6 +1,5 @@
percy
selenium
pandas
dash_table_experiments
xlrd
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed table experiment for the table while at it -- the experiment was causing problems in any case

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for the tests, or is the transition to 16 the end of the line for anyone still using experiments? Which would be fine, but it would mean we need to be very clear about this with users.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this because I was having issues with the experiment. Will check if this is end-of-line or just usage details.

Copy link
Contributor Author

@Marc-Andre-Rivet Marc-Andre-Rivet Apr 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, will not looking further into this. The issue might be limited to the old import { PropTypes } from 'react' usage, maybe there's more to it.

test('DatePickerRange renders', () => {
const dps = render(<DatePickerRange />);
const dps = render(<DatePickerRange {...defaultProps} />);
Copy link
Contributor Author

@Marc-Andre-Rivet Marc-Andre-Rivet Apr 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These props are required when running the React dev build like in Jest. Otherwise console errors prevent the tests from passing.

start_date.send_keys("1997-05-03")
self.wait_for_text_to_equal('#date-picker-range-output', 'None - None')

# updated both dates, callback should now fire and update output
dt_length = len(end_date.get_attribute('value'))
end_date.send_keys(dt_length * Keys.BACKSPACE)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When used IRL the behaviour is ok (override existing text on click) -- but in Selenium this seems to be an issue now. Delete with backspace all characters..

dt_input_3.send_keys("1997-05-03")

dt_input_4 = self.driver.find_element_by_css_selector(
'#dt-range-no-date-values-init-month #endDate'
)
self.driver.find_element_by_css_selector(
'label'
).click()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we are passing a valid value to react-dates, the calendar opens -- the alternative is throwing an error and crashing the render, not great.. all this means it's in the way when trying to select another component. Clicking something safe to close it.

dest[key] = null;

if (key === 'initial_visible_month') {
dest[key] = moment();
Copy link
Contributor Author

@Marc-Andre-Rivet Marc-Andre-Rivet Apr 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So apparently an invalid moment value is not good enough for initial_visible_month but is fine for everything else, doing moment() on the other hand uses the current month..

@@ -23,7 +23,7 @@ import Tab from './components/Tab.react';
import Store from './components/Store.react';
import LogoutButton from './components/LogoutButton.react';

import './components/css/[email protected].css';
import 'react-dates/lib/css/_datepicker.css';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As before, doing this here because Jest can't process css files for some reason that I don't feel like figuring out.

if (setProps && date !== null) {

this.setState({date});
if (date) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setProps check is now usless

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole if may be useless, if we accept #511

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I saw the PR :)


this.setState({start_date, end_date});

if (start_date && !start_date.isSame(old_start_date)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.isSame, .isBefore, .isAfter are functions offered by moment to compare moment objects to various time formats

@@ -1,7 +1,8 @@
import 'react-dates/initialize';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting with react-dates 13+ that's required

@Marc-Andre-Rivet Marc-Andre-Rivet marked this pull request as ready for review April 4, 2019 23:14
Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💃 Glad to finally get this up to date!

@Marc-Andre-Rivet Marc-Andre-Rivet merged commit cc3ac2e into master Apr 9, 2019
@Marc-Andre-Rivet Marc-Andre-Rivet deleted the react-16 branch September 25, 2019 10:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants