react_on_rails 11.1.8 → 12.0.0.pre.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +320 -0
- data/.eslintignore +2 -1
- data/.eslintrc +30 -2
- data/.github/FUNDING.yml +1 -0
- data/.gitignore +3 -1
- data/.prettierignore +10 -0
- data/.prettierrc +23 -0
- data/.release-it.json +3 -0
- data/.rubocop.yml +37 -11
- data/.travis.yml +10 -20
- data/CHANGELOG.md +89 -3
- data/CONTRIBUTING.md +61 -80
- data/Gemfile +3 -5
- data/{COMM-LICENSE → REACT-ON-RAILS-PRO-LICENSE} +6 -9
- data/README.md +121 -71
- data/Rakefile +0 -7
- data/SUMMARY.md +10 -12
- data/book.json +5 -5
- data/docs/additional-reading/asset-pipeline.md +8 -16
- data/docs/additional-reading/images.md +1 -1
- data/docs/additional-reading/rails_view_rendering_from_inline_javascript.md +2 -1
- data/docs/additional-reading/react-helmet.md +30 -10
- data/docs/additional-reading/react-router.md +52 -75
- data/docs/additional-reading/server-rendering-tips.md +12 -7
- data/docs/additional-reading/upgrade-webpacker-v3-to-v4.md +10 -0
- data/docs/api/javascript-api.md +3 -3
- data/docs/api/redux-store-api.md +4 -2
- data/docs/api/view-helpers-api.md +17 -14
- data/docs/basics/configuration.md +64 -61
- data/docs/basics/deployment.md +1 -2
- data/docs/basics/i18n.md +44 -22
- data/docs/basics/installation-into-an-existing-rails-app.md +2 -2
- data/docs/basics/minitest-configuration.md +31 -0
- data/docs/basics/react-server-rendering.md +1 -1
- data/docs/basics/recommended-project-structure.md +1 -1
- data/docs/basics/{generator-functions-and-railscontext.md → render-functions-and-railscontext.md} +59 -21
- data/docs/basics/rspec-configuration.md +2 -2
- data/docs/basics/upgrading-react-on-rails.md +61 -3
- data/docs/basics/webpack-configuration.md +15 -1
- data/docs/contributor-info/errors-with-hooks.md +45 -0
- data/docs/contributor-info/pull-requests.md +44 -0
- data/docs/misc/doctrine.md +1 -1
- data/docs/{misc-pending → outdated}/code-splitting.md +13 -9
- data/docs/{additional-reading → outdated}/heroku-deployment.md +0 -6
- data/docs/{basics → outdated}/how-react-on-rails-works.md +3 -3
- data/docs/{misc-pending → outdated}/manual-installation-overview.md +5 -5
- data/docs/{additional-reading → outdated}/rails-assets-relative-paths.md +3 -3
- data/docs/{misc-pending → outdated}/rails-assets.md +4 -7
- data/docs/{misc → outdated}/rails3.md +0 -0
- data/docs/testimonials/hvmn.md +3 -3
- data/docs/testimonials/resortpass.md +13 -0
- data/docs/testimonials/testimonials.md +11 -1
- data/docs/tutorial.md +69 -28
- data/jest.config.js +4 -0
- data/lib/generators/react_on_rails/base_generator.rb +2 -2
- data/lib/generators/react_on_rails/dev_tests_generator.rb +2 -1
- data/lib/generators/react_on_rails/generator_helper.rb +4 -6
- data/lib/generators/react_on_rails/install_generator.rb +2 -0
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev +3 -1
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-hmr +18 -0
- data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +20 -40
- data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +4 -8
- data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/store/helloWorldStore.js +1 -3
- data/lib/react_on_rails.rb +4 -1
- data/lib/react_on_rails/configuration.rb +15 -23
- data/lib/react_on_rails/error.rb +2 -0
- data/lib/react_on_rails/git_utils.rb +2 -0
- data/lib/react_on_rails/helper.rb +111 -162
- data/lib/react_on_rails/json_output.rb +1 -1
- data/lib/react_on_rails/json_parse_error.rb +2 -0
- data/lib/react_on_rails/locales/base.rb +142 -0
- data/lib/react_on_rails/locales/to_js.rb +37 -0
- data/lib/react_on_rails/locales/to_json.rb +27 -0
- data/lib/react_on_rails/prerender_error.rb +11 -15
- data/lib/react_on_rails/react_component/render_options.rb +4 -0
- data/lib/react_on_rails/server_rendering_js_code.rb +42 -0
- data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +71 -51
- data/lib/react_on_rails/test_helper/ensure_assets_compiled.rb +7 -8
- data/lib/react_on_rails/utils.rb +15 -20
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/version_checker.rb +5 -1
- data/lib/react_on_rails/webpacker_utils.rb +16 -2
- data/lib/tasks/assets.rake +5 -45
- data/lib/tasks/locale.rake +8 -2
- data/package-scripts.yml +49 -0
- data/package.json +41 -31
- data/rakelib/dummy_apps.rake +1 -9
- data/rakelib/example_type.rb +3 -1
- data/rakelib/examples.rake +3 -0
- data/rakelib/lint.rake +2 -7
- data/rakelib/node_package.rake +2 -2
- data/rakelib/release.rake +3 -8
- data/rakelib/run_rspec.rake +5 -18
- data/react_on_rails.gemspec +3 -5
- data/tsconfig.json +14 -0
- data/webpackConfigLoader.js +5 -4
- data/yarn.lock +7042 -2327
- metadata +39 -57
- data/Gemfile.rails32 +0 -74
- data/docs/additional-reading/babel.md +0 -5
- data/docs/additional-reading/hot-reloading-rails-development-asset-pipeline.md +0 -47
- data/docs/api/ruby-api-hot-reload-view-helpers.md +0 -44
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-server +0 -12
- data/lib/react_on_rails/assets_precompile.rb +0 -150
- data/lib/react_on_rails/locales_to_js.rb +0 -136
data/Gemfile
CHANGED
@@ -15,14 +15,14 @@ gem "jbuilder"
|
|
15
15
|
gem "jquery-rails"
|
16
16
|
gem "mini_racer"
|
17
17
|
gem "puma"
|
18
|
-
|
19
18
|
gem "rails_12factor"
|
20
19
|
gem "ruby-lint", require: false
|
21
20
|
gem "sass-rails"
|
22
21
|
gem "scss_lint", require: false
|
23
22
|
gem "sdoc", group: :doc
|
24
23
|
gem "spring"
|
25
|
-
gem "
|
24
|
+
gem "sprockets", "~>3.0"
|
25
|
+
gem "sqlite3", "~> 1.3.6"
|
26
26
|
gem "turbolinks"
|
27
27
|
gem "uglifier"
|
28
28
|
gem "web-console", group: :development
|
@@ -30,13 +30,11 @@ gem "web-console", group: :development
|
|
30
30
|
# below are copied from spec/dummy/Gemfile
|
31
31
|
gem "capybara"
|
32
32
|
gem "capybara-screenshot"
|
33
|
-
gem "chromedriver-helper"
|
34
33
|
gem "launchy"
|
35
|
-
gem "poltergeist"
|
36
34
|
gem "rspec-rails"
|
37
35
|
gem "rspec-retry"
|
38
36
|
gem "selenium-webdriver"
|
39
|
-
gem "webpacker"
|
37
|
+
gem "webpacker", ">= 4.0.0"
|
40
38
|
|
41
39
|
gem "equivalent-xml", github: "mbklein/equivalent-xml"
|
42
40
|
gem "rainbow"
|
@@ -1,6 +1,7 @@
|
|
1
|
+
React on Rails Pro License
|
1
2
|
For React on Rails Pro, not the open source version. For open source, see https://github.com/shakacode/react_on_rails/blob/master/LICENSE.md.
|
2
3
|
|
3
|
-
Copyright (c) 2018 Justin Gordon and ShakaCode, http://www.shakacode.com
|
4
|
+
Copyright (c) 2018, 2019 Justin Gordon and ShakaCode, http://www.shakacode.com
|
4
5
|
|
5
6
|
All rights reserved.
|
6
7
|
|
@@ -19,7 +20,7 @@ In order to use the Software under this Agreement, you must receive a “Source
|
|
19
20
|
|
20
21
|
1.1 General Use. This Agreement grants you a non-exclusive, non-transferable, limited license to the use rights for the Software, without the right to grant sublicenses, subject to the terms and conditions in this Agreement. The Software is licensed, not sold.
|
21
22
|
|
22
|
-
1.2 Unlimited Organization License.
|
23
|
+
1.2 Unlimited Organization License. You may install the Software on an unlimited number of Hosts. “Host” means any physical or virtual machine which is controlled by you. You may concurrently run the software on an unlimited number of Hosts, with each host running an unlimited number of Workers.
|
23
24
|
|
24
25
|
1.3 Archive Copies. You are entitled to make a reasonable amount of copies of the Software for archival purposes. Each copy must reproduce all copyright and other proprietary rights notices on or in the Software Product.
|
25
26
|
|
@@ -33,15 +34,11 @@ In order to use the Software under this Agreement, you must receive a “Source
|
|
33
34
|
|
34
35
|
3.2 UNDER NO CIRCUMSTANCES MAY YOU USE THE SOFTWARE AS PART OF A PRODUCT OR SERVICE THAT PROVIDES SIMILAR FUNCTIONALITY TO THE SOFTWARE ITSELF.
|
35
36
|
|
36
|
-
The Open Source version of the Software (“LGPL Version”) is licensed
|
37
|
-
under the terms of the GNU Lesser General Public License versions 3.0
|
38
|
-
(“LGPL”) and not under this EULA.
|
39
|
-
|
40
37
|
4. Ownership. Notwithstanding anything to the contrary contained herein, except for the limited license rights expressly provided herein, ShakaCode and its suppliers have and will retain all rights, title and interest (including, without limitation, all patent, copyright, trademark, trade secret and other intellectual property rights) in and to the Software and all copies, modifications and derivative works thereof (including any changes which incorporate any of your ideas, feedback or suggestions). You acknowledge that you are obtaining only a limited license right to the Software, and that irrespective of any use of the words “purchase”, “sale” or like terms hereunder no ownership rights are being conveyed to you under this Agreement or otherwise.
|
41
38
|
|
42
39
|
5. Fees and Payment. The Software license fees will be due and payable in full as set forth in the applicable invoice or at the time of purchase. If the Software does not function properly within two weeks of purchase, please contact us within those two weeks for a refund. You shall be responsible for all taxes, withholdings, duties and levies arising from the order (excluding taxes based on the net income of ShakaCode).
|
43
40
|
|
44
|
-
6. Support, Maintenance and Services. Subject to the terms and conditions of this Agreement, as set forth in your invoice, and as set forth
|
41
|
+
6. Support, Maintenance and Services. Subject to the terms and conditions of this Agreement, as set forth in your invoice, and as set forth in the attached Master Service Agreement included with the purchase of your license subscription.
|
45
42
|
|
46
43
|
7. Term of Agreement.
|
47
44
|
|
@@ -52,6 +49,7 @@ under the terms of the GNU Lesser General Public License versions 3.0
|
|
52
49
|
7.3 Expiration of License. Upon the expiration of any term under this Agreement, (a) all Software updates and services pursuant to the license shall cease, (b) you may only continue to run existing installations of the Software, (c) you may not install the Software on any additional Hosts, and (d) any new installation of the Software shall require the purchase of a new license subscription from ShakaCode.
|
53
50
|
|
54
51
|
8. Disclaimer of Warranties. The Software is provided "as is," with all faults, defects and errors, and without warranty of any kind. ShakaCode does not warrant that the Software will be free of bugs, errors, viruses or other defects, and ShakaCode shall have no liability of any kind for the use of or inability to use the Software, the Software content or any associated service, and you acknowledge that it is not technically practicable for ShakaCode to do so.
|
52
|
+
|
55
53
|
To the maximum extent permitted by applicable law, ShakaCode disclaims all warranties, express, implied, arising by law or otherwise, regarding the Software, the Software content and their respective performance or suitability for your intended use, including without limitation any implied warranty of merchantability, fitness for a particular purpose.
|
56
54
|
|
57
55
|
9. Limitation of Liability.
|
@@ -72,12 +70,11 @@ In no event will ShakaCode's liability exceed the Software license price as indi
|
|
72
70
|
|
73
71
|
12. Third Party Software. Examples included in Software may provide links to third party libraries or code (collectively “Third Party Software”) to implement various functions. Third Party Software does not comprise part of the Software. In some cases, access to Third Party Software may be included along with the Software delivery as a convenience for demonstration purposes. Such source code and libraries may be included in the “…/examples” source tree delivered with the Software and do not comprise the Software. Licensee acknowledges (1) that some part of Third Party Software may require additional licensing of copyright and patents from the owners of such, and (2) that distribution of any of the Software referencing or including any portion of a Third Party Software may require appropriate licensing from such third parties.
|
74
72
|
|
75
|
-
|
76
73
|
13. Miscellaneous
|
77
74
|
|
78
75
|
13.1 Entire Agreement. This Agreement sets forth our entire agreement with respect to the Software and the subject matter hereof and supersedes all prior and contemporaneous understandings and agreements whether written or oral.
|
79
76
|
|
80
|
-
13.2 Amendment. ShakaCode reserves the right, in its sole discretion, to amend this Agreement from time. Amendments to this Agreement can be located at: https://github.com/shakacode/react_on_rails/blob/master/
|
77
|
+
13.2 Amendment. ShakaCode reserves the right, in its sole discretion, to amend this Agreement from time. Amendments to this Agreement can be located at: https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.
|
81
78
|
|
82
79
|
13.3 Assignment. You may not assign this Agreement or any of its rights under this Agreement without the prior written consent of ShakaCode and any attempted assignment without such consent shall be void.
|
83
80
|
|
data/README.md
CHANGED
@@ -1,10 +1,44 @@
|
|
1
|
-
|
1
|
+
![reactrails](https://user-images.githubusercontent.com/10421828/79436261-52159b80-7fd9-11ea-994e-2a98dd43e540.png)
|
2
2
|
|
3
|
-
|
3
|
+
<p align="center">
|
4
|
+
<a href="https://shakacode.com/"><img src="https://user-images.githubusercontent.com/10421828/79436256-517d0500-7fd9-11ea-9300-dfbc7c293f26.png"></a>
|
5
|
+
<a href="https://forum.shakacode.com/"><img src="https://user-images.githubusercontent.com/10421828/79436266-53df5f00-7fd9-11ea-94b3-b985e1b05bdc.png"></a>
|
6
|
+
<a href="https://forum.shakacode.com/t/react-on-rails-pro-2020-shave-the-yak/1842"><img src="https://user-images.githubusercontent.com/10421828/79436265-53df5f00-7fd9-11ea-8220-fc474f6a856c.png"></a>
|
7
|
+
<a href="https://github.com/sponsors/shakacode"><img src="https://user-images.githubusercontent.com/10421828/79466109-cdd90d80-8004-11ea-88e5-25f9a9ddcf44.png"></a>
|
8
|
+
</p>
|
4
9
|
|
10
|
+
---
|
11
|
+
|
12
|
+
[![License](https://img.shields.io/badge/license-mit-green.svg)](./LICENSE.md) [![Build Status](https://travis-ci.org/shakacode/react_on_rails.svg?branch=master)](https://travis-ci.org/shakacode/react_on_rails) [![Gem Version](https://badge.fury.io/rb/react_on_rails.svg)](https://badge.fury.io/rb/react_on_rails) [![npm version](https://badge.fury.io/js/react-on-rails.svg)](https://badge.fury.io/js/react-on-rails) [![Code Climate](https://codeclimate.com/github/shakacode/react_on_rails/badges/gpa.svg)](https://codeclimate.com/github/shakacode/react_on_rails) [![Coverage Status](https://coveralls.io/repos/shakacode/react_on_rails/badge.svg?branch=master&service=github)](https://coveralls.io/github/shakacode/react_on_rails?branch=master) [![](https://ruby-gem-downloads-badge.herokuapp.com/react_on_rails?type=total)](https://rubygems.org/gems/react_on_rails)
|
13
|
+
|
14
|
+
*These are the docs for React on Rails 12, coming soon. To see the version 11 docs, [click here](https://github.com/shakacode/react_on_rails/tree/11.3.0).*
|
15
|
+
|
16
|
+
#### News
|
17
|
+
**June 12, 2020**:
|
18
|
+
1. Gem version: 12.0.0.pre.beta.0 and npm version 12.0.0-beta.0 released! Please try this out!
|
19
|
+
Major enhancements:
|
20
|
+
1. Typescript bindings
|
21
|
+
2. Proper support for React Hooks
|
22
|
+
3. i18n support for generating a JSON file rather than a JS file.
|
23
|
+
2. See Justin's RailsConf talk: [Webpacker, It-Just-Works, But How?](http://railsconf.com/2020/video/justin-gordon-webpacker-it-just-works-but-how).
|
24
|
+
|
25
|
+
**April 2, 2020**:
|
26
|
+
* Are you interested in support for React on Rails? If so check out [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro).
|
27
|
+
* HMR is working with [Loadable Components](https://loadable-components.com) for a both amazing hot-reloading developer experience and great runtime performance. Please [email me](mailto:justin@shakacode.com) if you'd like to use [Loadable Components Code Splitting](https://loadable-components.com/docs/code-splitting/) to speed up your app by reducing your bundle sizes and lazily loading the code that's needed.
|
28
|
+
* `react_on_rails` fully supports `rails/webpacker`. The example test app in `spec/dummy` was recently converted over to use rails/webpacker v4. It's a good example of how to leverage rails/webpacker's webpack configuration.
|
29
|
+
|
30
|
+
---
|
31
|
+
|
32
|
+
#### About
|
5
33
|
React on Rails integrates Rails with (server rendering of) Facebook's [React](https://github.com/facebook/react) front-end framework.
|
6
34
|
|
7
|
-
|
35
|
+
This project is sponsored by the software consulting firm [ShakaCode](https://www.shakacode.com). We focus on React front-ends, often with Ruby on Rails or Gatsby. The best way to see what we do is to see the details of [our recent work](https://www.shakacode.com/recent-work).
|
36
|
+
|
37
|
+
Interested in optimizing your webpack setup for React on Rails including code splitting with react-router v4, webpack v4, and react-loadable with server side rendering? We just did this for Popmenu, [lowering Heroku costs 20-25% while getting a 73% decrease in average response times](https://www.shakacode.com/recent-work/popmenu/).
|
38
|
+
|
39
|
+
Feel free to contact Justin Gordon, [justin@shakacode.com](mailto:justin@shakacode.com), maintainer of React on Rails, for more information.
|
40
|
+
|
41
|
+
[Click to join **React + Rails Slack**](https://reactrails.slack.com/join/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE).
|
8
42
|
|
9
43
|
# Intro
|
10
44
|
|
@@ -17,62 +51,21 @@ To provide an opinionated and optimal framework for integrating Ruby on Rails wi
|
|
17
51
|
Given that rails/webpacker gem already provides basic React integration, why would you use "React on Rails"?
|
18
52
|
|
19
53
|
1. Server rendering, often used for SEO crawler indexing and UX performance, is not offered by rails/webpacker.
|
20
|
-
1. The easy passing of props directly from your Rails view to your React components rather than having your Rails view load and then make a separate
|
21
|
-
1. [Redux](https://github.com/reactjs/redux) and [React Router](https://github.com/reactjs/react-router) integration.
|
54
|
+
1. The easy passing of props directly from your Rails view to your React components rather than having your Rails view load and then make a separate request to your API.
|
55
|
+
1. [Redux](https://github.com/reactjs/redux) and [React Router](https://github.com/reactjs/react-router) integration with server-side-rendering.
|
22
56
|
1. [Internationalization (I18n) and (localization)](https://github.com/shakacode/react_on_rails/blob/master/docs/basics/i18n.md)
|
23
|
-
1. [RSpec Test Helpers Configuration](docs/basics/rspec-configuration.md) to ensure your Webpack bundles are ready for tests.
|
57
|
+
1. [RSpec Test Helpers Configuration](docs/basics/rspec-configuration.md) to ensure your Webpack bundles are ready for tests. _(and for [Minitest](docs/basics/minitest-configuration.md))._
|
24
58
|
1. A supportive community. This [web search shows how live public sites are using React on Rails](https://publicwww.com/websites/%22react-on-rails%22++-undeveloped.com/).
|
25
|
-
1. [Reason ML Support](https://github.com/shakacode/reason-react-on-rails-example)
|
59
|
+
1. [Reason ML Support](https://github.com/shakacode/reason-react-on-rails-example).
|
60
|
+
|
26
61
|
|
27
62
|
See the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial) for an example of a live implementation and code.
|
28
63
|
|
29
64
|
## ShakaCode Forum Premium Content
|
30
|
-
_Requires creating a free account._
|
65
|
+
_Requires creating a free account._
|
66
|
+
|
31
67
|
* [How to use different versions of a file for client and server rendering](https://forum.shakacode.com/t/how-to-use-different-versions-of-a-file-for-client-and-server-rendering/1352)
|
32
68
|
|
33
|
-
## React on Rails Pro and ShakaCode Pro Support
|
34
|
-
|
35
|
-
React on Rails Pro provides Node server rendering and other performance enhancements for React on Rails.
|
36
|
-
|
37
|
-
![2018-09-11_10-31-11](https://user-images.githubusercontent.com/1118459/45467845-5bcc7400-b6bd-11e8-91e1-e0cf806d4ea4.png)
|
38
|
-
|
39
|
-
* [HVMN Testimonial, Written by Paul Benigeri, October 12, 2018](./docs/testimonials/hvmn.md)
|
40
|
-
* [HVMN’s 90% Reduction in Server Response Time from React on Rails Pro](https://blog.shakacode.com/hvmns-90-reduction-in-server-response-time-from-react-on-rails-pro-eb08226687db)
|
41
|
-
* [Egghead React on Rails Pro Deployment Highlights](https://github.com/shakacode/react_on_rails/wiki/Egghead-React-on-Rails-Pro-Deployment-Highlights)
|
42
|
-
|
43
|
-
For more information, see the [React on Rails Pro Docs](https://github.com/shakacode/react_on_rails/wiki).
|
44
|
-
|
45
|
-
The [ShakaCode Pro Support Plan](http://www.shakacode.com/work/shakacode-pro-support.pdf) can help you with:
|
46
|
-
|
47
|
-
* Optimizing your webpack setup to Webpack v4 for React on Rails including code splitting with react-router v4, webpack v4, and react-loadable.
|
48
|
-
* Upgrading your app to use the current Webpack setup that skips the Sprockets asset pipeline.
|
49
|
-
* Better performance client and server side.
|
50
|
-
* Efficiently migrating from [Angular to React](https://www.shakacode.com/services/angular-to-react/).
|
51
|
-
* Best practices based on over four years of React on Rails experience.
|
52
|
-
* Using [Reason](https://reasonml.github.io/) with (or without) React on Rails.
|
53
|
-
|
54
|
-
ShakaCode can also help you with your custom software development needs. We specialize in marketplace and e-commerce applications that utilize both Rails and React. Because we own [HawaiiChee.com](https://www.hawaiichee.com), we can leverage that code for your app!
|
55
|
-
|
56
|
-
The article [Why Hire ShakaCode?](https://blog.shakacode.com/can-shakacode-help-you-4a5b1e5a8a63#.jex6tg9w9) provides additional details about our projects.
|
57
|
-
|
58
|
-
Please [email me (Justin Gordon), the creator of React on Rails](mailto:justin@shakacode.com), to see if I can help you or if you want an invite to our private Slack room for ShakaCode.
|
59
|
-
|
60
|
-
## Testimonials for Hiring ShakaCode and our "Pro Support"
|
61
|
-
|
62
|
-
[HVMN Testimonial, Written by Paul Benigeri, October 12, 2018](./docs/testimonials/hvmn.md)
|
63
|
-
|
64
|
-
> The price we paid for the consultation + the React on Rails pro license has already been made back a couple of times from hosting fees alone. The entire process was super hands off, and our core team was able to focus on shipping new feature during that sprint.
|
65
|
-
|
66
|
-
From Kyle Maune of Cooper Aerial, May 4, 2018
|
67
|
-
|
68
|
-
![image](https://user-images.githubusercontent.com/1118459/40891236-9b0b406e-671d-11e8-80ee-c026dbd1d5a2.png)
|
69
|
-
|
70
|
-
From Joel Hooks, Co-Founder, Chief Nerd at [egghead.io](https://egghead.io/), January 30, 2017:
|
71
|
-
|
72
|
-
![2017-01-30_11-33-59](https://cloud.githubusercontent.com/assets/1118459/22443635/b3549fb4-e6e3-11e6-8ea2-6f589dc93ed3.png)
|
73
|
-
|
74
|
-
For more testimonials, see [Live Projects](PROJECTS.md) and [Kudos](./KUDOS.md).
|
75
|
-
|
76
69
|
----
|
77
70
|
|
78
71
|
# Docs
|
@@ -90,7 +83,7 @@ Note, the best way to understand how to use ReactOnRails is to study a few simpl
|
|
90
83
|
1. Do the quick [tutorial](docs/tutorial.md).
|
91
84
|
2. Add React on Rails to an existing Rails app per [the instructions](docs/basics/installation-into-an-existing-rails-app.md).
|
92
85
|
3. Look at [spec/dummy](spec/dummy), a simple, no DB example.
|
93
|
-
3. Look at [github.com/shakacode/react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial); it's a full
|
86
|
+
3. Look at [github.com/shakacode/react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial); it's a full-featured example live at [www.reactrails.com](http://www.reactrails.com).
|
94
87
|
|
95
88
|
## Basic Installation
|
96
89
|
|
@@ -186,13 +179,14 @@ Below is the line where you turn server rendering on by setting `prerender` to t
|
|
186
179
|
<%= react_component("HelloWorld", props: { name: "Stranger" }) %>
|
187
180
|
```
|
188
181
|
|
189
|
-
- This is what your HelloWorld.js file might contain. The railsContext is always available for any parameters that you _always_ want available for your React components. It has _nothing_ to do with the concept of the [React Context](https://reactjs.org/docs/context.html). See [
|
182
|
+
- This is what your HelloWorld.js file might contain. The railsContext is always available for any parameters that you _always_ want available for your React components. It has _nothing_ to do with the concept of the [React Context](https://reactjs.org/docs/context.html). See [render functions and the RailsContext](docs/basics/render-functions-and-railscontext.md) for more details on this topic.
|
190
183
|
|
191
184
|
```js
|
192
185
|
import React from 'react';
|
193
186
|
|
194
187
|
export default (props, railsContext) => {
|
195
|
-
|
188
|
+
// Note wrap in a function to make this a React function component
|
189
|
+
return () => (
|
196
190
|
<div>
|
197
191
|
Your locale is {railsContext.i18nLocale}.<br/>
|
198
192
|
Hello, {props.name}!
|
@@ -205,7 +199,7 @@ See the [View Helpers API](./docs/api/view-helpers-api.md) for more details on `
|
|
205
199
|
|
206
200
|
## Fragment Caching
|
207
201
|
|
208
|
-
Fragment caching is a [React on Rails Pro](https://
|
202
|
+
Fragment caching is a [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro) feature. Fragment caching is a **HUGE** performance booster for your apps. Use the `cached_react_component` and `cached_react_component_hash`. The API is the same as `react_component` and `react_component_hash`, but for 2 differences:
|
209
203
|
|
210
204
|
1. The `cache_key` takes the same parameters as any Rails `cache` view helper.
|
211
205
|
1. The **props** are passed via a block so that evaluation of the props is not done unless the cache is broken. Suppose you put your props calculation into some method called `some_slow_method_that_returns_props`:
|
@@ -227,7 +221,7 @@ Note, even without server rendering (without step 3 above), fragment caching is
|
|
227
221
|
|
228
222
|
## Integration with Node.js for Server Rendering
|
229
223
|
|
230
|
-
Default server rendering is done by ExecJS. If you want to use a Node.js server for better performing server rendering, [email justin@shakacode.com](mailto:justin@shakacode.com). ShakaCode has built a premium Node rendering server that is part of [React on Rails Pro](https://
|
224
|
+
Default server rendering is done by ExecJS. If you want to use a Node.js server for better performing server rendering, [email justin@shakacode.com](mailto:justin@shakacode.com). ShakaCode has built a premium Node rendering server that is part of [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro).
|
231
225
|
|
232
226
|
## Globally Exposing Your React Components
|
233
227
|
|
@@ -252,21 +246,39 @@ Another way is to use a separate webpack configuration file that can use a diffe
|
|
252
246
|
|
253
247
|
For details on techniques to use different code for client and server rendering, see: [How to use different versions of a file for client and server rendering](https://forum.shakacode.com/t/how-to-use-different-versions-of-a-file-for-client-and-server-rendering/1352). (_Requires creating a free account._)
|
254
248
|
|
255
|
-
## Specifying Your React Components:
|
249
|
+
## Specifying Your React Components: Register directly or use render-functions
|
256
250
|
|
257
|
-
You have two ways to specify your React components. You can either register the React component directly, or you can create a function that returns a React component
|
251
|
+
You have two ways to specify your React components. You can either register the React component (either function or class component) directly, or you can create a function that returns a React component, which we using the name of a "render-function". Creating a render-function allows:
|
258
252
|
|
259
|
-
1. You have access to the `railsContext`. See documentation for the railsContext in terms of why you might need it. You **need** a
|
253
|
+
1. You have access to the `railsContext`. See documentation for the railsContext in terms of why you might need it. You **need** a render function to access the `railsContext`.
|
260
254
|
2. You can use the passed-in props to initialize a redux store or set up react-router.
|
261
255
|
3. You can return different components depending on what's in the props.
|
262
256
|
|
263
|
-
|
257
|
+
Note, the return value of a **render function** should be either a React Function or Class Component, or an object representing server rendering results.
|
258
|
+
|
259
|
+
Do not return a React Element (JSX).
|
260
|
+
|
261
|
+
ReactOnRails will automatically detect a registered render function by the fact that the function takes
|
262
|
+
more than 1 parameter. In other words, if you want the ability to provide a function that returns the
|
263
|
+
React component, then you need to specify at least a second parameter. This is the `railsContext`.
|
264
|
+
If you're not using this parameter, declare your function with the unused param:
|
265
|
+
|
266
|
+
```js
|
267
|
+
const MyComponentGenerator = (props, _railsContext) => {
|
268
|
+
if (props.print) {
|
269
|
+
// This is a React FunctionComponent because it is wrapped in a function.
|
270
|
+
return () => <H1>{JSON.stringify(props)}</H1>;
|
271
|
+
}
|
272
|
+
}
|
273
|
+
```
|
274
|
+
|
275
|
+
Thus, there is no difference between registering a React function or class Component versus a "render function."
|
264
276
|
|
265
|
-
## react_component_hash for
|
277
|
+
## react_component_hash for render functions
|
266
278
|
|
267
|
-
Another reason to use a
|
279
|
+
Another reason to use a render function is that sometimes in server rendering, specifically with React Router, you need to return the result of calling ReactDOMServer.renderToString(element). You can do this by returning an object with the following shape: { renderedHtml, redirectLocation, error }. Make sure you use this function with `react_component_hash`.
|
268
280
|
|
269
|
-
For server rendering, if you wish to return multiple HTML strings from a
|
281
|
+
For server rendering, if you wish to return multiple HTML strings from a render function, you may return an Object from your render function with a single top-level property of `renderedHtml`. Inside this Object, place a key called `componentHtml`, along with any other needed keys. An example scenario of this is when you are using side effects libraries like [React Helmet](https://github.com/nfl/react-helmet). Your Ruby code will get this Object as a Hash containing keys componentHtml and any other custom keys that you added:
|
270
282
|
|
271
283
|
```js
|
272
284
|
{ renderedHtml: { componentHtml, customKey1, customKey2} }
|
@@ -281,7 +293,8 @@ For details on using react_component_hash with react-helmet, see the docs below
|
|
281
293
|
|
282
294
|
## I18n
|
283
295
|
|
284
|
-
|
296
|
+
React on Rails provides an option for automatic conversions of Rails `*.yml` locale files into `*.json` or `*.js*.
|
297
|
+
See the [How to add I18n](docs/basics/i18n.md) for a summary of adding I18n.
|
285
298
|
|
286
299
|
## More Details
|
287
300
|
|
@@ -289,18 +302,16 @@ Browse the links in the [Summary Table of Contents](./SUMMARY.md)
|
|
289
302
|
|
290
303
|
Here are some highly recommended next articles to read:
|
291
304
|
|
292
|
-
1. [How React on Rails Works](
|
305
|
+
1. [How React on Rails Works](docs/outdated/how-react-on-rails-works.md)
|
293
306
|
1. [Recommended Project Structure](./docs/basics/recommended-project-structure.md)
|
294
307
|
1. [Webpack Configuration](./docs/basics/webpack-configuration.md)
|
295
308
|
1. [View Helpers API](./docs/api/view-helpers-api.md)
|
296
|
-
1. [Caching and Performance: React on Rails Pro](https://
|
309
|
+
1. [Caching and Performance: React on Rails Pro](https://www.shakacode.com/react-on-rails-pro).
|
297
310
|
1. [Deployment](docs/basics/deployment.md).
|
298
311
|
|
299
312
|
# Support
|
300
313
|
|
301
|
-
|
302
|
-
|
303
|
-
Aloha, I'm Justin Gordon the creator and maintainer of React on Rails. I'm supporting my continued dedication to this project by project by offering a React on Rails **Pro Support Plan**. Please [email me](mailto:justin@shakacode.com) to see if I can help you.
|
314
|
+
[Click to join **React + Rails Slack**](https://reactrails.slack.com/join/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE).
|
304
315
|
|
305
316
|
## Community Resources
|
306
317
|
|
@@ -319,19 +330,58 @@ Please [**click to subscribe**](https://app.mailerlite.com/webforms/landing/l1d9
|
|
319
330
|
|
320
331
|
Bug reports and pull requests are welcome. See [Contributing](CONTRIBUTING.md) to get started, and the [list of help wanted issues](https://github.com/shakacode/react_on_rails/labels/contributions%3A%20up%20for%20grabs%21).
|
321
332
|
|
333
|
+
## React on Rails Pro
|
334
|
+
|
335
|
+
React on Rails Pro provides Node server rendering, fragment caching, code-splitting, and other performance enhancements for React on Rails. For a case study, see the article [HVMN’s 90% Reduction in Server Response Time from React on Rails Pro](https://blog.shakacode.com/hvmns-90-reduction-in-server-response-time-from-react-on-rails-pro-eb08226687db). The [Wiki](https://github.com/shakacode/react_on_rails/wiki) contains more details.
|
336
|
+
|
337
|
+
[![2018-09-11_10-31-11](https://user-images.githubusercontent.com/1118459/45467845-5bcc7400-b6bd-11e8-91e1-e0cf806d4ea4.png)](https://blog.shakacode.com/hvmns-90-reduction-in-server-response-time-from-react-on-rails-pro-eb08226687db)
|
338
|
+
|
339
|
+
## React on Rails Pro Support
|
340
|
+
|
341
|
+
The [React on Rails Pro Support Plan](https://www.shakacode.com/react-on-rails-pro) can help!
|
342
|
+
|
343
|
+
* Optimizing your webpack setup to Webpack v4 for React on Rails including code splitting with react-router v4, webpack v4, and react-loadable.
|
344
|
+
* Upgrading your app to use the current Webpack setup that skips the Sprockets asset pipeline.
|
345
|
+
* Better performance client and server side.
|
346
|
+
* Best practices based on over four years of React on Rails experience.
|
347
|
+
* Using [Reason](https://reasonml.github.io/) with (or without) React on Rails.
|
348
|
+
|
349
|
+
ShakaCode can also help you with your custom software development needs. We specialize in marketplace and e-commerce applications that utilize both Rails and React. Because we own [HawaiiChee.com](https://www.hawaiichee.com), we can leverage that code for your app!
|
350
|
+
|
351
|
+
Please email Justin Gordon [justin@shakacode.com](mailto:justin@shakacode.com), the maintainer of React on Rails, for more information.
|
352
|
+
|
353
|
+
## Testimonials for ShakaCode
|
354
|
+
[HVMN Testimonial, by Paul Benigeri, October 12, 2018](./docs/testimonials/hvmn.md)
|
355
|
+
> The price we paid for the consultation + the React on Rails pro license has already been made back a couple of times from hosting fees alone. The entire process was super hands off, and our core team was able to focus on shipping new feature during that sprint.
|
356
|
+
|
357
|
+
[ResortPass Testimonial, by Leora Juster, December 10, 2018](./docs/testimonials/resortpass.md)
|
358
|
+
|
359
|
+
> Justin and his team were instrumental in assisting us in setting design foundations and standards for our transition to a react on rails application. Just three months of work with the team at Shaka code and we have a main page of our application server-side rendering at exponentially improved speeds.
|
360
|
+
|
361
|
+
From Joel Hooks, Co-Founder, Chief Nerd at [egghead.io](https://egghead.io/), January 30, 2017:
|
362
|
+
|
363
|
+
![2017-01-30_11-33-59](https://cloud.githubusercontent.com/assets/1118459/22443635/b3549fb4-e6e3-11e6-8ea2-6f589dc93ed3.png)
|
364
|
+
|
365
|
+
For more testimonials, see [Live Projects](PROJECTS.md) and [Kudos](./KUDOS.md).
|
366
|
+
|
322
367
|
# Supporters
|
323
368
|
|
324
|
-
The following companies support this open source project, and ShakaCode uses their products! Justin writes React on Rails on [RubyMine](https://www.jetbrains.com/ruby/). We use [Scout](https://scoutapp.com/) to monitor the live performance of [HawaiiChee.com](https://www.hawaiichee.com),
|
369
|
+
The following companies support this open source project, and ShakaCode uses their products! Justin writes React on Rails on [RubyMine](https://www.jetbrains.com/ruby/). We use [Scout](https://scoutapp.com/) to monitor the live performance of [HawaiiChee.com](https://www.hawaiichee.com), [BrowserStack](https://www.browserstack.com) to solve problems with oddball browsers, and [CodersRank](https://codersrank.io/) to find candidates for our team.
|
325
370
|
|
371
|
+
[![2019-09-24_17-48-00](https://user-images.githubusercontent.com/1118459/65567887-96353780-def3-11e9-926d-4a55e2e186ff.png)](https://www.jetbrains.com/ruby/)
|
326
372
|
[![Scout](https://user-images.githubusercontent.com/1118459/41828269-106b40f8-77d0-11e8-8d19-9c4b167ef9d8.png)](https://scoutapp.com/)
|
327
373
|
[![BrowserStack](https://cloud.githubusercontent.com/assets/1118459/23203304/1261e468-f886-11e6-819e-93b1a3f17da4.png)](https://www.browserstack.com)
|
374
|
+
[![CodersRank](https://user-images.githubusercontent.com/1118459/55040254-ad8a7b00-4fcb-11e9-8936-c6765eb30698.png)](https://codersrank.io/?utm_source=github&utm_medium=banner&utm_campaign=shakacode)
|
375
|
+
|
376
|
+
## Clubhouse
|
377
|
+
I've just moved ShakaCode's development to [ClubHouse](https://clubhouse.io/) from Trello. We're going to be doing this with all our projects. If you want to **try ClubHouse and get 2 months free beyond the 14-day trial period**, click [here to use ShakaCode's referral code](http://r.clbh.se/mvfoNeH). We're participating in their awesome triple-sided referral program, which you can read about [here](https://clubhouse.io/blog/clubhouse-referral-program-5f614bb437c3). By using our [referral code](http://r.clbh.se/mvfoNeH) you'll be supporting ShakaCode and, thus, React on Rails!
|
328
378
|
|
329
379
|
*If you'd like to support React on Rails and have your company listed here, [get in touch](mailto:justin@shakacode.com).*
|
330
380
|
|
331
381
|
Aloha and best wishes from Justin and the ShakaCode team!
|
332
382
|
|
333
383
|
# Work with Us
|
334
|
-
ShakaCode is **[currently looking to hire](http://www.shakacode.com/about/#work-with-us)** like-minded, remote-first, developers that wish to work on our projects, including [Hawaii Chee](https://www.hawaiichee.com). Your main coding interview will be pairing with us on our open source! We're
|
384
|
+
ShakaCode is **[currently looking to hire](http://www.shakacode.com/about/#work-with-us)** like-minded, remote-first, developers that wish to work on our projects, including [Hawaii Chee](https://www.hawaiichee.com). Your main coding interview will be pairing with us on our open source! We're also using [ReasonML](https://reasonml.github.io/) extensively!
|
335
385
|
|
336
386
|
# License
|
337
387
|
|
data/Rakefile
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
# Rake will automatically load any *.rake files inside of the "rakelib" folder
|
4
4
|
# See rakelib/
|
5
5
|
|
6
|
-
require_relative "./spec/react_on_rails/support/rails32_helper"
|
7
|
-
|
8
6
|
tasks = %w[run_rspec lint]
|
9
7
|
prepare_for_ci = %w[node_package dummy_apps]
|
10
8
|
|
@@ -14,11 +12,6 @@ if ENV["USE_COVERALLS"] == "TRUE"
|
|
14
12
|
tasks << "coveralls:push"
|
15
13
|
end
|
16
14
|
|
17
|
-
if using_rails32?
|
18
|
-
tasks = %w[run_rspec:gem_rails32 run_rspec:dummy_no_webpacker]
|
19
|
-
prepare_for_ci = %w[node_package dummy_apps:dummy_no_webpacker]
|
20
|
-
end
|
21
|
-
|
22
15
|
desc "Run all tests and linting"
|
23
16
|
task default: tasks
|
24
17
|
|
data/SUMMARY.md
CHANGED
@@ -5,15 +5,16 @@
|
|
5
5
|
## **Basics**
|
6
6
|
+ [React on Rails Basic Installation Tutorial](./docs/tutorial.md)
|
7
7
|
+ [Webpack Configuration](./docs/basics/webpack-configuration.md)
|
8
|
-
+ [How React on Rails Works](
|
8
|
+
+ [How React on Rails Works](docs/outdated/how-react-on-rails-works.md)
|
9
9
|
+ [Client vs. Server Rendering](./docs/basics/client-vs-server-rendering.md)
|
10
10
|
+ [React Server Rendering](./docs/basics/react-server-rendering.md)
|
11
11
|
+ [Recommended Project Structure](./docs/basics/recommended-project-structure.md)
|
12
|
-
+ [
|
12
|
+
+ [Render-Functions and the RailsContext](docs/basics/render-functions-and-railscontext.md)
|
13
13
|
+ [Caching and Performance: React on Rails Pro](https://github.com/shakacode/react_on_rails/wiki).
|
14
14
|
+ [Deployment](docs/basics/deployment.md).
|
15
15
|
+ [React on Rails Internationalization (I18n, localization)](docs/basics/i18n.md)
|
16
16
|
+ [RSpec Test Helpers Configuration](docs/basics/rspec-configuration.md)
|
17
|
+
+ [Minitest Configuration](docs/basics/minitest-configuration.md)
|
17
18
|
+ [Upgrading React on Rails](docs/basics/upgrading-react-on-rails.md)
|
18
19
|
|
19
20
|
## **API**
|
@@ -25,34 +26,31 @@
|
|
25
26
|
+ [Migration from react-rails](./docs/basics/migrating-from-react-rails.md)
|
26
27
|
+ [Generator Details](docs/basics/generator-details.md)
|
27
28
|
+ [Updating Dependencies](./docs/additional-reading/updating-dependencies.md)
|
28
|
-
+ [Manual Installation Overview](docs/
|
29
|
+
+ [Manual Installation Overview](docs/outdated/manual-installation-overview.md)
|
30
|
+
+ [Upgrading from rails/webpacker v3 to v4](docs/additional-reading/upgrade-webpacker-v3-to-v4.md)
|
29
31
|
|
30
32
|
## **Rails**
|
31
33
|
+ [Rails Engine Integration](./docs/additional-reading/rails-engine-integration.md)
|
32
34
|
+ [Rails View Rendering from Inline JavaScript](./docs/additional-reading/rails_view_rendering_from_inline_javascript.md)
|
33
35
|
+ [Turbolinks](./docs/additional-reading/turbolinks.md)
|
34
|
-
+ [Rails Assets](docs/misc-pending/rails-assets.md)
|
35
36
|
+ [Converting a Rails 5 API only app to a Rails app](./docs/additional-reading/convert-rails-5-api-only-app.md)
|
36
37
|
|
37
38
|
## **Javascript**
|
38
39
|
+ [Node Dependencies, NPM, and Yarn](./docs/additional-reading/node-dependencies-and-npm.md)
|
39
|
-
+ [Babel](./docs/additional-reading/babel.md)
|
40
40
|
+ [React Router](./docs/additional-reading/react-router.md)
|
41
41
|
+ [React & Redux](./docs/additional-reading/react-and-redux.md)
|
42
|
-
+ [Webpack Tips](./docs/additional-reading/webpack
|
42
|
+
+ [Webpack Tips](./docs/additional-reading/webpack.md)
|
43
43
|
+ [Server Rendering Tips](./docs/additional-reading/server-rendering-tips.md)
|
44
|
-
+ [Code Splitting](docs/
|
44
|
+
+ [Code Splitting](docs/outdated/code-splitting.md)
|
45
45
|
+ [AngularJS Integration and Migration to React on Rails](./docs/additional-reading/angular-js-integration-migration.md)
|
46
46
|
|
47
47
|
## **Deployment**
|
48
|
-
+ [Heroku Deployment](
|
48
|
+
+ [Heroku Deployment](docs/outdated/heroku-deployment.md)
|
49
49
|
+ [Elastic Beanstalk Deployment](./docs/additional-reading/elastic-beanstalk.md)
|
50
50
|
|
51
|
-
##
|
52
|
-
+ [Setting up Hot Reloading during Rails Development, API docs](./docs/api/ruby-api-hot-reload-view-helpers.md)
|
51
|
+
## Outdated Non-Webpack Docs
|
53
52
|
+ [Developing with the Webpack Dev Server](./docs/additional-reading/webpack-dev-server.md)
|
54
|
-
+ [Webpack, the Asset Pipeline, and Using Assets w/ React](./docs/
|
55
|
-
+ [Hot Reloading of Assets For Rails Development for Asset Pipeline](docs/additional-reading/hot-reloading-rails-development-asset-pipeline.md)
|
53
|
+
+ [Webpack, the Asset Pipeline, and Using Assets w/ React](./docs/outdated/rails-assets-relative-paths.md)
|
56
54
|
|
57
55
|
## **[CONTRIBUTING](CONTRIBUTING.md)**
|
58
56
|
+ [Generator Testing](./docs/contributor-info/generator-testing.md)
|