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

Update React to 16.3 #18768

Merged
merged 4 commits into from May 14, 2018
Merged

Update React to 16.3 #18768

merged 4 commits into from May 14, 2018

Conversation

timroes
Copy link
Contributor

@timroes timroes commented May 3, 2018

This PR just updates React to 16.3 for Kibana and x-pack.

I already have my Inspector branch build upon 16.3 and just wanted to merge that in at some point in time. But since that feature might take another few weeks and 16.3 brings some important lifecycle changes, I wanted to create a separate PR for this update.

That way people who are currently developing React components could already make use of the new life-cycle methods, before I merged the Inspector. Also once this is merged, I could write a mail with information about the new lifecycle and make devs aware of #17432. With every week we don't update this, we potentially create new React components, that will later need refactoring again, so I hope we can do this update as soon as possible.

This also turns of two eslint rules, that will anyway be noop in the future for React 16.3 according to jsx-eslint/eslint-plugin-react#1754.

Also I updated one snapshot, that was failing due to the update, because React 16.3, doesn't assign the value="on" for checkboxes, but therefore a value="" for empty managed text fields by default.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@epixa
Copy link
Contributor

epixa commented May 3, 2018

@timroes At the moment, EUI and Kibana are both using 16.2. Since we're relying on EUI so heavily, and more every day, we really should be bumping EUI as well to ensure compatibility.

@cjcenizal
Copy link
Contributor

We're tracking this in elastic/eui#763.

@@ -118,8 +118,9 @@ module.exports = {
'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
'react/jsx-equals-spacing': ['error', 'never'],
'react/jsx-indent': ['error', 2],
'react/no-did-mount-set-state': 'error',
'react/no-did-update-set-state': 'error',
// Off as of React 16.3, see https://github.com/yannickcr/eslint-plugin-react/issues/1754
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be a good thing to add:

{
  "settings": {
    "react": {
      "version": "16.3"
    }
  }
}

It sounds like the solution upstream may be to noop those rules based on the React pragma version.

Seems like the actionable thing to do here is, when the React version pragma is >= v16.3, these rules should no-op.

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 added that react version to the .eslintrc config in Kibana, since the eslint-config-kibana actually doesn't have any knowledge about the React version Kibana is using.

'react/no-did-update-set-state': 'error',
// Off as of React 16.3, see https://github.com/yannickcr/eslint-plugin-react/issues/1754
'react/no-did-mount-set-state': 'off',
'react/no-did-update-set-state': 'off',
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason these need to be set to off and not just removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. I thought we extend the recommended config, but since we didn't we can simply remove them :-)

@@ -1,6 +1,6 @@
{
"name": "@elastic/eslint-config-kibana",
"version": "0.15.0",
"version": "0.16.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless you're publishing this to NPM, please don't increment the version number

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

LGTM

@timroes
Copy link
Contributor Author

timroes commented May 8, 2018

@cjcenizal good to see this. So the only important step is, that we merge this PR before the third step of your EUI plan. The first two steps are completly decoupled and won't benefit from updating or not updating via this PR.

@timroes timroes merged commit f579d22 into elastic:master May 14, 2018
@timroes timroes deleted the react-16.3 branch May 14, 2018 12:05
timroes added a commit to timroes/kibana that referenced this pull request May 14, 2018
* Update React to 16.3

* Switch off specific eslint rules

* Update enzyme snapshots

* Incorporate PR feedback
timroes added a commit that referenced this pull request May 14, 2018
* Update React to 16.3

* Switch off specific eslint rules

* Update enzyme snapshots

* Incorporate PR feedback
@@ -118,8 +118,6 @@ module.exports = {
'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
'react/jsx-equals-spacing': ['error', 'never'],
'react/jsx-indent': ['error', 2],
'react/no-did-mount-set-state': 'error',
'react/no-did-update-set-state': 'error',
Copy link
Member

Choose a reason for hiding this comment

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

Not related to the React bump but thought I'd put it here:
Are we still trying to follow airbnb's convention (with minor modifications) or do we see our style guide as very different?

If we still intent to follow airbnb style, wouldn't it be nicer if we extended their rules? Their react rules look pretty similar:
https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb/rules/react.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants