Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates react to 16.6 (latest) #24707

Merged
merged 9 commits into from
Jan 23, 2019
Merged

Conversation

jasonrhodes
Copy link
Member

@jasonrhodes jasonrhodes commented Oct 28, 2018

Summary

Upgrades the following packages to "latest" in order to keep our React dependencies up to date.

  • react
  • react-dom
  • enzyme
  • enzyme-adapter-react-16
  • enzyme-adapter-utils
  • enzyme-to-json

These deps have been updated in the kibana root as well as in the x-pack directory. I'm not sure if it needs to be upgraded in other places or if there is a kbn command to do these kinds of upgrades across the project.

NOTES:

  • This PR can replace Upgrade react and react-dom to 16.5.2 #23437 which was upgrading these dependencies to a now-older version. (ping @markov00)
  • Upgrading the enzyme packages resolved all but 2 of the jest unit test failures in the x-pack folder.
  • There are 42 failing snapshots in the kibana root jest run, but almost all of them are due to the fact that React no longer seems to render <React.Fragment> in snapshot tests, or in some cases renders as <Fragment> instead of <React.Fragment>.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@jasonrhodes jasonrhodes added chore WIP Work in progress labels Oct 28, 2018
@elasticmachine
Copy link
Contributor

💔 Build Failed

@jasonrhodes
Copy link
Member Author

retest

@elasticmachine
Copy link
Contributor

💔 Build Failed

@markov00
Copy link
Member

Thanks @jasonrhodes for doing this. also @sqren was interested in doing this.

About the React.Fragment thing, yes it's a change in the enzyme adapter (but I cannot find a changelog that describe exactly what changed), I already seen this in the EUI.

The x-pack failures are a bit strange, seems that they are requiring the adapter but it's loaded via x-pack/dev-tools/jest/setup/enzyme.js.

@sorenlouv
Copy link
Member

Can't wait for the hooks either? :D

@jasonrhodes
Copy link
Member Author

Can't wait for the hooks either? :D

Suspennnnnnnnnse

@spalger
Copy link
Contributor

spalger commented Nov 3, 2018

I tried to do basically the same thing but was concerned by some of the snapshot changes I was seeing, which led me to find the change in getDerivedStateFromProps() behavior introduced in 16.4 and file several issues for components that will need to be updated before we can upgrade:

All other uses of getDerivedStateFromProps() were either compatible with calls before each render, or were in components that didn't use setState().

@spalger
Copy link
Contributor

spalger commented Nov 29, 2018

@jasonrhodes All those issues are closed now, want to take another shot at this upgrade?

@elasticmachine
Copy link
Contributor

💔 Build Failed

@jasonrhodes
Copy link
Member Author

@spalger absolutely, will give this a shot tomorrow -- thanks for the heads up!

@jasonrhodes
Copy link
Member Author

I rebased this against master and re-ran tests, here are the results. In the Kibana root:

Test Suites: 30 failed, 1 skipped, 490 passed, 520 of 521 total
Tests:       53 failed, 1 skipped, 3428 passed, 3482 total
Snapshots:   51 failed, 1017 passed, 1068 total

In x-pack:

Test Suites: 39 failed, 288 passed, 327 total
Tests:       70 failed, 1719 passed, 1789 total
Snapshots:   70 failed, 626 passed, 696 total

In both cases, these are primarily due to <React.Fragment> becoming <Fragment> in snapshots. I will go through and update all snapshots that are only failing because of this fragment change and report back about the remaining failures.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@jasonrhodes
Copy link
Member Author

After fixing/updating snapshots where <React.Fragment> changed to <Fragment> or, in some cases, disappeared, we still have about 35 failing tests for React 16.

For Kibana root:

Test Suites: 10 failed, 1 skipped, 510 passed, 520 of 521 total
Tests:       18 failed, 1 skipped, 3463 passed, 3482 total
Snapshots:   16 failed, 1052 passed, 1068 total

and for x-pack:

Test Suites: 12 failed, 315 passed, 327 total
Tests:       16 failed, 1773 passed, 1789 total
Snapshots:   16 failed, 680 passed, 696 total

So that's roughly 30 snapshots and 2 unit tests that need some review. A lot of those 30 snapshots are still related to <React.Fragment> but the diffs are so involved that I didn't want to just u them too easily, so I'd appreciate a couple more sets of eyes before mashing them through.

@spalger @chandlerprall @sqren @ogupte @markov00 or anyone else wanna have a go?

@jasonrhodes jasonrhodes requested review from a team as code owners January 3, 2019 20:47
@jasonrhodes
Copy link
Member Author

Also note: the "+12000" lines in the diff is almost entirely because the yarn.lock file was missing from the x-pack folder for some reason, and this PR added it back since I ran bootstrap to get the updated deps sorted. Not sure why it was missing?

@legrego
Copy link
Member

legrego commented Jan 3, 2019

^^ @joshdover did your work on yarn workspaces intentionally remove this? I seem to remember you mentioning something about it, but I might be making that up

@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<ImpactedSpacesFlyout> renders without crashing 1`] = `
<React.Fragment>
<Fragment>
Copy link
Member

Choose a reason for hiding this comment

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

question: Why do some of the snapshot differences change <React.Fragment> => <Fragment>, whereas others just remove the fragment altogether, like this example?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a good question. I looked into it a bit and couldn't find a solid answer. I looked at some of the source and nothing changed, it seemed like possibly when there is a single fragment inside of another single element, the fragment may disappear since it's "not needed" but I'm not totally sure if that's true.

Copy link
Contributor

@chandlerprall chandlerprall Jan 4, 2019

Choose a reason for hiding this comment

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

Enzyme has removed fragments from rendered output since roughly 3.3.5 or 3.3.6 - https://github.com/airbnb/enzyme/blame/master/packages/enzyme/src/RSTTraversal.js#L25

Copy link
Contributor

Choose a reason for hiding this comment

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

Dug in a bit more; in cases where the Fragment is the top-level/ROOT/HOST node (as it is in ImpactedSpacesFlyout> renders without crashing 1), then the Fragment is never seen as a child so it doesn't get expanded.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@sorenlouv
Copy link
Member

sorenlouv commented Jan 5, 2019

Really awesome work on upgrading React! Would it make sense to bump it to the latest (16.7) now you are at it? 16.7 is supposedly fully backwards compatible with 16.6, and was only labelled as a minor release (instead of patch) to err on the side of caution.
https://reactjs.org/blog/2018/12/19/react-v-16-7.html

@joshdover
Copy link
Contributor

@legrego @jasonrhodes Right, there should only be a single yarn.lock file now. If you had started this before yarn-workspaces was merged you probably got a conflict on the x-pack/yarn.lock. That file should be removed from your PR.

@jasonrhodes
Copy link
Member Author

@legrego @jasonrhodes Right, there should only be a single yarn.lock file now. If you had started this before yarn-workspaces was merged you probably got a conflict on the x-pack/yarn.lock. That file should be removed from your PR.

But I think running yarn kbn bootstrap still creates it ... that's going to be a problem isn't it?

@joshdover
Copy link
Contributor

@jasonrhodes That shouldn't be the case. If you delete the file and run bootstrap again, is it re-appearing?

@jasonrhodes
Copy link
Member Author

@joshdover i'll try when I have a minute to get back on this branch. All I know is that the file was already missing for me when I rebased this branch, I believe, and running bootstrap to update the react deps seemed to re-create it. I'll try again and confirm, though.

@joshdover
Copy link
Contributor

joshdover commented Jan 9, 2019

@jasonrhodes Definitely seems strange. We've updated other dependencies since workspaces went in and this hasn't happened. I think what happened here is that this work was started before workspaces went in and git may have put the file back when you merged/rebased with master.

If it does reappear after deleting/bootstrap again, lmk and I can help investigate.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@jasonrhodes
Copy link
Member Author

@Bargs @chandlerprall this commit is pushed 4893cba

That fixes the issue with the query_bar blocking state updates due to the 16.4 changes with getDerivedStateFromProps running on every render and not just on prop updates. Give me a thumbs up if you take a look and think this solves the problem safely. Thanks!

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@chandlerprall
Copy link
Contributor

@jasonrhodes same snapshot update needed for x-pack tests (executeQueryOptions prop appearing)

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

Changes + snapshot updates look great

Copy link
Contributor

@Bargs Bargs left a comment

Choose a reason for hiding this comment

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

Query bar change LGTM

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@jasonrhodes jasonrhodes removed the WIP Work in progress label Jan 23, 2019
@jasonrhodes
Copy link
Member Author

@joshdover / @legrego you all have commented here in the past so I'm pinging you for a last look/approval :D

Copy link
Member

@legrego legrego left a comment

Choose a reason for hiding this comment

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

LGTM!

@jasonrhodes
Copy link
Member Author

@stacey-gammon do you want to look at anything here, with a React upgrade?

@jasonrhodes jasonrhodes merged commit a11e471 into elastic:master Jan 23, 2019
@jasonrhodes jasonrhodes deleted the react-16.6 branch January 23, 2019 18:46
jasonrhodes added a commit to jasonrhodes/kibana that referenced this pull request Jan 23, 2019
* Updates react to 16.6 (latest)

* Updated fragment-based snapshots for Kibana root unit tests

* Updated fragment-based snapshots for x-pack unit tests

* Removed xpack yarn.lock file bc it is no longer needed, it was reintroduced by accident during a rebase in this branch

* React 16.6 snapshot updates, round 2 (mostly Fragment snapshot diffs)

* Updated last round of React 16.6 snapshots

* Fixes query bar issue with 16.4 gDSFP lifecycle

* Updated yarn lock (arraybuffer.slice updated)

* Updates snapshots where executeQueryOptions prop appears
jasonrhodes added a commit that referenced this pull request Jan 23, 2019
* Updates react to 16.6 (latest)

* Updated fragment-based snapshots for Kibana root unit tests

* Updated fragment-based snapshots for x-pack unit tests

* Removed xpack yarn.lock file bc it is no longer needed, it was reintroduced by accident during a rebase in this branch

* React 16.6 snapshot updates, round 2 (mostly Fragment snapshot diffs)

* Updated last round of React 16.6 snapshots

* Fixes query bar issue with 16.4 gDSFP lifecycle

* Updated yarn lock (arraybuffer.slice updated)

* Updates snapshots where executeQueryOptions prop appears
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants