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 to react 16 #792

Merged
merged 24 commits into from
Oct 9, 2017
Merged

Update to react 16 #792

merged 24 commits into from
Oct 9, 2017

Conversation

BookOfGreg
Copy link
Member

@BookOfGreg BookOfGreg commented Sep 27, 2017

Based on facebook's blog posts and deprecation warnings

  • Update React Builds to 16
    • react-addons-transition-group to react-transition-group/TransitionGroup
    • react-addons-css-transition-group to react-transition-group/CSSTransitionGroup
    • react-addons-update to immutability-helper
    • react-addons-test-utils to react-dom/test-utils
    • Removed: react-addons-linked-state-mixin
    • Removed: react-addons-create-fragment
    • Removed: react-addons-pure-render-mixin
    • Removed: react-addons-perf
  • Update generators to be compatible with 16
  • Find appropriate place to require("create-react-class") if we use that rather than ES6. In React_UJS perhaps?
    • Put prop-types in bundle
    • Put create-react-class in addons
  • Update Dummy apps in test suite
    • Deprecated use of old React features
    • Update to newer Libv8 (and miniracer)
    • Handle "any" prop issue by removing addons

Fixes #790

This PR is very unlikely to be backwards compatible with React 15

  • Addons in the prepackaged build have changed; some have direct replacements but not all, those that don't have different API's.
  • Changes like create-class will change how our generators work.

Reference: https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html

Replace -> With
react-addons-transition-group -> react-transition-group/TransitionGroup
react-addons-css-transition-group -> react-transition-group/CSSTransitionGroup
react-addons-update -> immutability-helper
react-addons-test-utils -> react-dom/test-utils

Removed
react-addons-linked-state-mixin
  use Value and onChange
react-addons-create-fragment
  React16 has fragments
react-addons-pure-render-mixin
  use React.PureComponent
react-addons-perf
  see https://facebook.github.io/react/docs/optimizing-performance.html#profiling-components-with-the-chrome-performance-tab
@@ -129,15 +129,23 @@ def component_name

def file_header
if webpacker?
%|var React = require("react")\n|
if options[:es6]
Copy link
Member

Choose a reason for hiding this comment

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

Is it important to distinguish between these two varieties of preprocessed JS? I mean, what's the scenario where you want require(...) but not import?

Anyone who's using webpacker will probably already use Babel (for JSX), right? So do you think one of these options would be sufficient by itself?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was tempted to scrap all the old style generators but was not sure on the effect it would have with sprockets + babel transpiler. I did what looked safe given I still don't fully know the system and saw the option[:es6] used nearby in the same file.
Will continue on this path a little this afternoon, seems like the most pressing issue for now, then maybe the HMR ( 793 ) thing after once I get time.

@BookOfGreg
Copy link
Member Author

BookOfGreg commented Oct 1, 2017

@rmosolgo
The only failing tests on bundle exec appraisal rails-5_no_sprockets_webpacker_3 rake test are around ExecJS::ProgramError: TypeError: Cannot read property 'any' of undefined which I've tracked back to addons.TransitionGroup = require("react-transition-group/TransitionGroup"); which seems to include component.PropType.any which is always undefined.

I couldn't find a way of getting it to accept the migration to prop-types so I'm considering dropping the addons packages given React 16 doesn't do addons anymore anyway.

Thoughts?
I'm thinking a release on the 2.3 branch to just do React 15.6 without all the deprecation warnings, and then for React 16 no addons.

@rmosolgo
Copy link
Member

rmosolgo commented Oct 1, 2017

Yeah, I guess there are other ways to get addons these days, so it's not as important to bundle them here. That two-release plan sounds good, that seems like it would be easier for people to migrate, too.

@BookOfGreg
Copy link
Member Author

Previous version has 3k downloads. Not hearing anything about bugs in its use. Tempting to get ready to merge this one in.

@rmosolgo
Copy link
Member

rmosolgo commented Oct 6, 2017

Do your thing 😎

@BookOfGreg BookOfGreg merged commit 0ef92cc into master Oct 9, 2017
@BookOfGreg BookOfGreg deleted the update-to-react-16 branch October 9, 2017 08:17
BookOfGreg added a commit that referenced this pull request Jul 27, 2019
Add pry-byebug for ease of debugging.
Update the locally used react_ujs to 2.5.0
BookOfGreg added a commit that referenced this pull request Jul 27, 2019
* Upgrade all Yarn deps in Test folders

* Migrate to webdrivers gem

* Revert Bundle Renderer test to before #792

Add pry-byebug for ease of debugging.
Update the locally used react_ujs to 2.5.0

* Use travis recommended chrome config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants