react_on_rails 12.0.2 → 12.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +12 -2
  3. data/.eslintrc +2 -1
  4. data/.github/workflows/lint-js-and-ruby.yml +53 -0
  5. data/.github/workflows/main.yml +178 -0
  6. data/.github/workflows/package-js-tests.yml +35 -0
  7. data/.github/workflows/rspec-package-specs.yml +45 -0
  8. data/.prettierrc +0 -3
  9. data/.rubocop.yml +46 -38
  10. data/CHANGELOG.md +35 -12
  11. data/CONTRIBUTING.md +4 -3
  12. data/Gemfile +1 -33
  13. data/Gemfile.development_dependencies +51 -0
  14. data/README.md +63 -55
  15. data/docs/{basics → additional-details}/generator-details.md +1 -6
  16. data/docs/{outdated → additional-details}/manual-installation-overview.md +6 -6
  17. data/docs/{basics → additional-details}/migrating-from-react-rails.md +0 -0
  18. data/docs/{additional-reading → additional-details}/recommended-project-structure.md +0 -0
  19. data/docs/{additional-reading → additional-details}/updating-dependencies.md +0 -0
  20. data/docs/additional-details/upgrade-webpacker-v3-to-v4.md +10 -0
  21. data/docs/api/javascript-api.md +2 -2
  22. data/docs/api/redux-store-api.md +3 -3
  23. data/docs/api/view-helpers-api.md +7 -8
  24. data/docs/basics/client-vs-server-rendering.md +3 -3
  25. data/docs/basics/configuration.md +42 -25
  26. data/docs/basics/deployment.md +2 -2
  27. data/docs/basics/hmr-and-hot-reloading-with-the-webpack-dev-server.md +16 -14
  28. data/docs/{outdated → basics}/how-react-on-rails-works.md +8 -9
  29. data/docs/basics/installation-into-an-existing-rails-app.md +13 -6
  30. data/docs/basics/react-server-rendering.md +3 -3
  31. data/docs/basics/rspec-configuration.md +10 -10
  32. data/docs/{tutorial.md → basics/tutorial.md} +23 -31
  33. data/docs/basics/upgrading-react-on-rails.md +32 -12
  34. data/docs/basics/webpack-configuration.md +4 -6
  35. data/docs/contributor-info/linters.md +5 -6
  36. data/docs/contributor-info/pull-requests.md +2 -4
  37. data/docs/contributor-info/releasing.md +1 -1
  38. data/docs/{additional-reading → deployment}/elastic-beanstalk.md +0 -0
  39. data/docs/{basics → deployment}/heroku-deployment.md +0 -0
  40. data/docs/home.md +382 -0
  41. data/docs/{additional-reading → javascript}/angular-js-integration-migration.md +0 -0
  42. data/docs/{additional-reading → javascript}/asset-pipeline.md +0 -0
  43. data/docs/{additional-reading → javascript}/capistrano-deployment.md +0 -0
  44. data/docs/{outdated → javascript}/code-splitting.md +5 -5
  45. data/docs/{additional-reading → javascript}/converting-from-custom-webpack-config-to-rails-webpacker-config.md +3 -3
  46. data/docs/{additional-reading → javascript}/credits.md +0 -0
  47. data/docs/{additional-reading → javascript}/foreman-issues.md +0 -0
  48. data/docs/{additional-reading → javascript}/images.md +5 -6
  49. data/docs/{additional-reading → javascript}/node-dependencies-and-npm.md +0 -0
  50. data/docs/{additional-reading → javascript}/react-and-redux.md +0 -0
  51. data/docs/{additional-reading → javascript}/react-helmet.md +0 -0
  52. data/docs/{additional-reading → javascript}/react-router.md +0 -0
  53. data/docs/{additional-reading → javascript}/server-rendering-tips.md +0 -0
  54. data/docs/{additional-reading → javascript}/troubleshooting-when-using-webpacker.md +0 -0
  55. data/docs/{additional-reading → javascript}/webpack-v1-notes.md +0 -0
  56. data/docs/{additional-reading → javascript}/webpack.md +0 -0
  57. data/docs/{articles.md → misc/articles.md} +1 -1
  58. data/docs/misc/doctrine.md +5 -5
  59. data/docs/{coding-style → misc}/style.md +0 -0
  60. data/docs/{additional-reading → misc}/tips.md +0 -0
  61. data/docs/outdated/deferred-rendering.md +39 -0
  62. data/docs/outdated/rails-assets-relative-paths.md +3 -3
  63. data/docs/outdated/rails-assets.md +8 -8
  64. data/docs/outdated/rails3.md +2 -2
  65. data/docs/rails-webpacker-react-integration-options.md +182 -0
  66. data/docs/{additional-reading → rails}/convert-rails-5-api-only-app.md +1 -1
  67. data/docs/{additional-reading → rails}/rails-engine-integration.md +0 -0
  68. data/docs/{additional-reading → rails}/rails_view_rendering_from_inline_javascript.md +0 -0
  69. data/docs/{additional-reading → rails}/turbolinks.md +0 -0
  70. data/docs/testimonials/testimonials.md +6 -6
  71. data/lib/generators/react_on_rails/base_generator.rb +8 -1
  72. data/lib/generators/react_on_rails/dev_tests_generator.rb +1 -1
  73. data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +8 -2
  74. data/lib/generators/react_on_rails/templates/dev_tests/spec/simplecov_helper.rb +1 -1
  75. data/lib/generators/react_on_rails/templates/dev_tests/spec/{features → system}/hello_world_spec.rb +2 -2
  76. data/lib/react_on_rails/configuration.rb +2 -0
  77. data/lib/react_on_rails/git_utils.rb +3 -3
  78. data/lib/react_on_rails/helper.rb +15 -9
  79. data/lib/react_on_rails/locales/base.rb +3 -3
  80. data/lib/react_on_rails/locales/to_js.rb +0 -4
  81. data/lib/react_on_rails/locales/to_json.rb +0 -4
  82. data/lib/react_on_rails/prerender_error.rb +1 -1
  83. data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +6 -6
  84. data/lib/react_on_rails/test_helper.rb +2 -0
  85. data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +1 -1
  86. data/lib/react_on_rails/utils.rb +19 -3
  87. data/lib/react_on_rails/version.rb +1 -1
  88. data/lib/react_on_rails/webpacker_utils.rb +5 -1
  89. data/lib/tasks/assets.rake +20 -11
  90. data/package.json +24 -29
  91. data/rakelib/docker.rake +0 -5
  92. data/rakelib/lint.rake +3 -9
  93. data/rakelib/release.rake +27 -13
  94. data/rakelib/run_rspec.rake +10 -11
  95. data/rakelib/task_helpers.rb +16 -4
  96. data/react_on_rails.gemspec +3 -17
  97. data/yarn.lock +2272 -4960
  98. metadata +50 -225
  99. data/docs/additional-reading/upgrade-webpacker-v3-to-v4.md +0 -10
  100. data/docs/additional-reading/webpack-dev-server.md +0 -15
  101. data/ruby-lint.yml +0 -25
data/CHANGELOG.md CHANGED
@@ -16,9 +16,29 @@ Please follow the recommendations outlined at [keepachangelog.com](http://keepac
16
16
  Changes since last non-beta release.
17
17
 
18
18
  *Please add entries here for your pull requests that are not yet released.*
19
+
20
+ ### [12.1.0] - 2021-03-23
21
+ #### Added
22
+ - Added the ability to assign a module with a `call` method to `config.build_production_command`. See [the configuration docs](./docs/basics/configuration.md). [PR 1362: Accept custom module for config.build_production_command](https://github.com/shakacode/react_on_rails/pull/1362).
23
+
24
+ #### Fixed
25
+ - Stop setting NODE_ENV value during precompile, as it interferred with rails/webpacker's setting of NODE_ENV to production by default. Fixes [#1334](https://github.com/shakacode/react_on_rails/issues/1334). [PR 1356: Don't set NODE_ENV in assets.rake](https://github.com/shakacode/react_on_rails/pull/1356) by [alexrozanski](https://github.com/alexrozanski).
26
+
27
+ ### [12.0.4] - 2020-11-14
28
+ #### Fixed
29
+ - Install generator now specifies the version. Fixes [React on Rails Generator installs the older npm package #1336](https://github.com/shakacode/react_on_rails/issues/1336). [PR 1338Fix Generator to use Exact NPM Version](https://github.com/shakacode/react_on_rails/pull/1338) by [justin808](https://github.com/justin808).
30
+
31
+ ### [12.0.3] - 2020-09-20
32
+ #### Fixed
33
+ - Async script loading optimizes page load speed. With this fix, a bundle
34
+ can be loaded "async" and a handler function can determine when to hydrate.
35
+ For an example of this, see the [docs for loadable-components SSR](https://loadable-components.com/docs/server-side-rendering/#4-add-loadableready-client-side).
36
+ [PR 1327](https://github.com/shakacode/react_on_rails/pull/1327) by [justin808](https://github.com/justin808).
37
+ Loadable-Components is supported by [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro).
38
+
19
39
  ### [12.0.2] - 2020-07-09
20
40
  #### Fixed
21
- - Remove dependency upon Redux for Typescript types [PR 1323](https://github.com/shakacode/react_on_rails/pull/1306) by [justin808](https://github.com/justin808).
41
+ - Remove dependency upon Redux for Typescript types. [PR 1323](https://github.com/shakacode/react_on_rails/pull/1306) by [justin808](https://github.com/justin808).
22
42
 
23
43
  ### [12.0.1] - 2020-07-09
24
44
  #### Fixed
@@ -44,8 +64,8 @@ invoked to return the React component. In that case, you won't need to pass any
44
64
  See [docs/basics/upgrading-react-on-rails](./docs/basics/upgrading-react-on-rails.md#upgrading-to-v12)
45
65
  for details.
46
66
 
47
- #### Other Updates
48
- * `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 for server-side rendering.
67
+ #### Other Updates
68
+ * `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 for server-side rendering.
49
69
  * Changed the precompile task to use the rails/webpacker one by default
50
70
  * Updated generators to use React hooks
51
71
  * Requires the use of rails/webpacker view helpers
@@ -60,19 +80,19 @@ for details.
60
80
  * Added configuration option `same_bundle_for_client_and_server` with default `false` because
61
81
 
62
82
  1. Production applications would typically have a server bundle that differs from the client bundle
63
- 2. This change only affects trying to use HMR with react_on_rails with rails/webpacker.
64
-
65
- The previous behavior was to always go to the webpack-dev-server for the server bundle if the
66
- webpack-dev-server was running _and_ the server bundle was found in the `manifest.json`.
67
-
83
+ 2. This change only affects trying to use HMR with react_on_rails with rails/webpacker.
84
+
85
+ The previous behavior was to always go to the webpack-dev-server for the server bundle if the
86
+ webpack-dev-server was running _and_ the server bundle was found in the `manifest.json`.
87
+
68
88
  If you are using the **same bundle for client and server rendering**, then set this configuration option
69
89
  to `true`. By [justin808](https://github.com/shakacode/react_on_rails/pull/1240).
70
-
90
+
71
91
  * Added support to export locales in JSON format. New option added `i18n_output_format` which allows to
72
92
  specify locales format either `JSON` or `JS`. **`JSON` format is now the default.**
73
-
93
+
74
94
  **Use this config setting to get the old behavior: config.i18n_output_format = 'js'**
75
-
95
+
76
96
  [PR 1271](https://github.com/shakacode/react_on_rails/pull/1271) by [ashgaliyev](https://github.com/ashgaliyev).
77
97
 
78
98
  - Added Typescript definitions to the Node package. By [justin808](https://github.com/justin808) and [judahmeek](https://github.com/judahmeek) in [PR 1287](https://github.com/shakacode/react_on_rails/pull/1287).
@@ -934,7 +954,10 @@ Best done with Object destructing:
934
954
  ##### Fixed
935
955
  - Fix several generator related issues.
936
956
 
937
- [Unreleased]: https://github.com/shakacode/react_on_rails/compare/12.0.2...master
957
+ [Unreleased]: https://github.com/shakacode/react_on_rails/compare/12.1.0...master
958
+ [12.1.0]: https://github.com/shakacode/react_on_rails/compare/12.0.4...12.1.0
959
+ [12.0.4]: https://github.com/shakacode/react_on_rails/compare/12.0.3...12.0.4
960
+ [12.0.3]: https://github.com/shakacode/react_on_rails/compare/12.0.2...12.0.3
938
961
  [12.0.2]: https://github.com/shakacode/react_on_rails/compare/12.0.1...12.0.2
939
962
  [12.0.1]: https://github.com/shakacode/react_on_rails/compare/12.0.0...12.0.1
940
963
  [12.0.0]: https://github.com/shakacode/react_on_rails/compare/11.3.0...12.0.0
data/CONTRIBUTING.md CHANGED
@@ -5,6 +5,7 @@
5
5
  * See other docs in [docs/contributor-info](./docs/contributor-info)
6
6
 
7
7
  ## To run tests:
8
+ * [Yalc](https://github.com/whitecolor/yalc) must be installed globally for most local development.
8
9
  * After updating code via git, to prepare all examples and run all tests:
9
10
 
10
11
  ```sh
@@ -62,9 +63,9 @@ cd react_on_rails/
62
63
  yarn
63
64
 
64
65
  # Update the lib directory with babel compiled files
65
- yarn run build:watch
66
+ yarn run build-watch
66
67
  ```
67
-
68
+
68
69
  You need to do this once:
69
70
 
70
71
  ```
@@ -192,7 +193,7 @@ Then run `bundle`.
192
193
 
193
194
  The main installer can be run with ```rails generate react_on_rails:install```
194
195
 
195
- Then use yalc to add the npm module.
196
+ Then use yalc to add the npm module.
196
197
 
197
198
  Be sure that your ran this first at the top level of React on Rails
198
199
 
data/Gemfile CHANGED
@@ -5,36 +5,4 @@ source "https://rubygems.org"
5
5
  # Specify your gem"s dependencies in react_on_rails.gemspec
6
6
  gemspec
7
7
 
8
- # The following gems are dependencies of the gem's dummy/example apps, not the gem itself.
9
- # They must be defined here because of the way Travis CI works, in that it will only
10
- # bundle install from a single Gemfile. Therefore, all gems that we will need for any dummy/example
11
- # app have to be manually added to this file.
12
- gem "bootsnap", ">= 1.1.0", require: false
13
- gem "bootstrap-sass"
14
- gem "jbuilder"
15
- gem "jquery-rails"
16
- gem "mini_racer"
17
- gem "puma"
18
- gem "rails_12factor"
19
- gem "ruby-lint", require: false
20
- gem "sass-rails"
21
- gem "scss_lint", require: false
22
- gem "sdoc", group: :doc
23
- gem "spring"
24
- gem "sprockets", "~>3.0"
25
- gem "sqlite3", "~> 1.3.6"
26
- gem "turbolinks"
27
- gem "uglifier"
28
- gem "web-console", group: :development
29
-
30
- # below are copied from spec/dummy/Gemfile
31
- gem "capybara"
32
- gem "capybara-screenshot"
33
- gem "launchy"
34
- gem "rspec-rails"
35
- gem "rspec-retry"
36
- gem "selenium-webdriver"
37
- gem "webpacker", ">= 4.0.0"
38
-
39
- gem "equivalent-xml", github: "mbklein/equivalent-xml"
40
- gem "rainbow"
8
+ eval_gemfile File.expand_path("./Gemfile.development_dependencies", __dir__)
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ gem "webpacker"
4
+ gem "bootsnap", require: false
5
+ gem "rails"
6
+ gem "sqlite3"
7
+ gem "sass-rails"
8
+ gem "uglifier"
9
+ gem "jquery-rails"
10
+ gem "puma"
11
+
12
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
13
+ gem "turbolinks" if ENV["DISABLE_TURBOLINKS"].nil? || ENV["DISABLE_TURBOLINKS"].strip.empty?
14
+
15
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
16
+ gem "jbuilder"
17
+ # bundle exec rake doc:rails generates the API under doc/api.
18
+ gem "sdoc", group: :doc
19
+
20
+ gem "sprockets"
21
+
22
+ gem "amazing_print"
23
+ gem "mini_racer"
24
+
25
+ group :development, :test do
26
+ gem "listen"
27
+ gem "pry"
28
+ gem "pry-byebug"
29
+ gem "pry-doc"
30
+ gem "pry-rails"
31
+ gem "pry-rescue"
32
+ gem "rubocop", require: false
33
+ gem "rubocop-performance", require: false
34
+ gem "rubocop-rspec", require: false
35
+ gem "scss_lint", require: false
36
+ gem "spring"
37
+ end
38
+
39
+ group :test do
40
+ gem "capybara"
41
+ gem "capybara-screenshot"
42
+ gem "coveralls", require: false
43
+ gem "equivalent-xml"
44
+ gem "generator_spec"
45
+ gem "launchy"
46
+ gem "rspec_junit_formatter"
47
+ gem "rspec-rails"
48
+ gem "rspec-retry"
49
+ gem "selenium-webdriver"
50
+ gem "webdrivers", "3.9.4"
51
+ end
data/README.md CHANGED
@@ -3,17 +3,23 @@
3
3
  <p align="center">
4
4
  <a href="https://shakacode.com/"><img src="https://user-images.githubusercontent.com/10421828/79436256-517d0500-7fd9-11ea-9300-dfbc7c293f26.png"></a>
5
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>
6
+ <a href="https://www.shakacode.com/react-on-rails-pro"><img src="https://user-images.githubusercontent.com/10421828/79436265-53df5f00-7fd9-11ea-8220-fc474f6a856c.png"></a>
7
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
8
  </p>
9
9
 
10
10
  ---
11
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)
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
13
 
14
14
  *These are the docs for React on Rails 12. To see the version 11 docs, [click here](https://github.com/shakacode/react_on_rails/tree/11.3.0).*
15
15
 
16
16
  #### News
17
+ **October 14, 2020**: [RUBY ROGUES
18
+ RR 474: React on Rails V12 – Don’t Shave That Yak! with Justin Gordon](https://devchat.tv/ruby-rogues/rr-474-react-on-rails-v12-dont-shave-that-yak-with-justin-gordon/).
19
+
20
+ **October 1, 2020**: See the [spec/dummy](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy) example repo for a simple configuration of webpack via the rails/webpacker gem
21
+ that supports SSR.
22
+
17
23
  **August 2, 2020**: See the example repo of [React on Rails Tutorial With SSR, HMR fast refresh, and TypeScript](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh) for a new way to setup the creation of your SSR bundle with `rails/webpacker`.
18
24
 
19
25
  **July 8, 2020**: Release v12 of React on Rails.
@@ -24,15 +30,13 @@
24
30
  2. **Typescript bindings**
25
31
  3. **rails/webpacker** "just works" with React on Rails by default.
26
32
  4. i18n support for generating a JSON file rather than a JS file.
27
-
28
- Be sure to see the [CHANGELOG.md](./CHANGELOG.md) and read the upgrade instructions:
29
- [docs/basics/upgrading-react-on-rails](./docs/basics/upgrading-react-on-rails.md#upgrading-to-v12).
30
-
33
+
34
+ Be sure to see the [CHANGELOG.md](https://github.com/shakacode/react_on_rails/tree/master/CHANGELOG.md) and read the upgrade instructions:
35
+ [docs/basics/upgrading-react-on-rails](https://www.shakacode.com/react-on-rails/docs/basics/upgrading-react-on-rails#upgrading-to-v12).
36
+
31
37
  * See Justin's RailsConf talk: [Webpacker, It-Just-Works, But How?](http://railsconf.com/2020/video/justin-gordon-webpacker-it-just-works-but-how).
32
- * 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).
38
+ * Are you interested in support for React on Rails? Do you want to use Node.js to do your server-side rendering so libraries like Emotion and Loadable Components just work, as compared to rendering via Ruby embedded JS? If so check out [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro).
33
39
  * 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.
34
- * `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.
35
-
36
40
  ---
37
41
 
38
42
  #### About
@@ -41,7 +45,7 @@ React on Rails integrates Rails with (server rendering of) Facebook's [React](ht
41
45
  This project is maintained by the software consulting firm [ShakaCode](https://www.shakacode.com). We focus on Ruby on Rails applications with React front-ends, often using TypeScript or ReasonML. We also build Gatsby sites. See [our recent work](https://www.shakacode.com/recent-work) for examples of what we do.
42
46
 
43
47
  Interested in optimizing your webpack setup for React on Rails including code
44
- splitting with [react-router](https://github.com/ReactTraining/react-router#readme),
48
+ splitting with [react-router](https://github.com/ReactTraining/react-router#readme),
45
49
  and [loadable-components](https://loadable-components.com/) with server-side rendering?
46
50
  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/).
47
51
 
@@ -57,28 +61,31 @@ To provide a high performance framework for integrating Ruby on Rails with React
57
61
 
58
62
  ## Features and Why React on Rails?
59
63
 
60
- Given that `rails/webpacker` gem already provides basic React integration, why would you use "React on Rails"?
64
+ Given that `rails/webpacker` gem already provides basic React integration, why would you use "React on Rails"?
61
65
 
62
66
  1. 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.
63
67
  1. Tight integration with [rails/webpacker](https://github.com/rails/webpacker).
64
68
  1. Server-Side Rendering (SSR), often used for SEO crawler indexing and UX performance, is not offered by `rails/webpacker`.
65
69
  1. [Redux](https://github.com/reactjs/redux) and [React Router](https://github.com/ReactTraining/react-router#readme) integration with server-side-rendering.
66
- 1. [Internationalization (I18n) and (localization)](https://github.com/shakacode/react_on_rails/blob/master/docs/basics/i18n.md)
67
- 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/).
70
+ 1. [Internationalization (I18n) and (localization)](https://www.shakacode.com/react-on-rails/docs/basics/i18n)
71
+ 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+depth%3Aall/).
68
72
  1. [Reason ML Support](https://github.com/shakacode/reason-react-on-rails-example).
69
73
 
74
+ See [Rails/Webpacker React Integration Options](./docs/rails-webpacker-react-integration-options.md) for comparisons to other gems.
75
+
70
76
  See the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial) for an example of a live implementation and code.
71
77
 
72
78
  ## ShakaCode Forum Premium Content
73
79
  _Requires creating a free account._
74
-
80
+
75
81
  * [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)
82
+ * [How to conditionally render server side based on the device type](https://forum.shakacode.com/t/how-to-conditionally-render-server-side-based-on-the-device-type/1473)
76
83
 
77
84
  ----
78
85
 
79
86
  # Docs
80
87
 
81
- **Consider browsing this on our [documentation Gitbook](https://shakacode.gitbooks.io/react-on-rails/content/).**
88
+ **Consider browsing this on our [website](https://www.shakacode.com/react-on-rails/docs/).**
82
89
 
83
90
  ## Prerequisites
84
91
 
@@ -86,16 +93,16 @@ Ruby on Rails >=5 and rails/webpacker 4.2+.
86
93
 
87
94
  ## Getting Started
88
95
 
89
- Note, the best way to understand how to use ReactOnRails is to study a few simple examples. You can do a quick demo setup, either on your existing app or on a new Rails app.
96
+ Note, the best way to understand how to use ReactOnRails is to study a few simple examples. You can do a quick demo setup, either on your existing app or on a new Rails app.
90
97
 
91
- 1. Do the quick [tutorial](docs/tutorial.md).
92
- 2. Add React on Rails to an existing Rails app per [the instructions](docs/basics/installation-into-an-existing-rails-app.md).
93
- 3. Look at [spec/dummy](spec/dummy), a simple, no DB example.
98
+ 1. Do the quick [tutorial](https://www.shakacode.com/react-on-rails/docs/basics/tutorial).
99
+ 2. Add React on Rails to an existing Rails app per [the instructions](https://www.shakacode.com/react-on-rails/docs/basics/installation-into-an-existing-rails-app).
100
+ 3. Look at [spec/dummy](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy), a simple, no DB example.
94
101
  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).
95
102
 
96
103
  ## Basic Installation
97
104
 
98
- *See also [the instructions for installing into an existing Rails app](docs/basics/installation-into-an-existing-rails-app.md).*
105
+ *See also [the instructions for installing into an existing Rails app](https://www.shakacode.com/react-on-rails/docs/basics/installation-into-an-existing-rails-app).*
99
106
 
100
107
  2. Add the `react_on_rails` gem to Gemfile:
101
108
 
@@ -119,7 +126,7 @@ Note, the best way to understand how to use ReactOnRails is to study a few simpl
119
126
 
120
127
  7. Visit http://localhost:3000/hello_world.
121
128
 
122
-
129
+
123
130
  ### Turning on server rendering
124
131
 
125
132
  With the code from running the React on Rails generator above:
@@ -142,8 +149,8 @@ issue.
142
149
 
143
150
  ### Configuration
144
151
 
145
- * Configure `config/initializers/react_on_rails.rb`. You can adjust some necessary settings and defaults. See file [docs/basics/configuration.md](docs/basics/configuration.md) for documentation of all configuration options.
146
- * Configure `config/webpacker.yml`. If you used the generator and the default webpacker setup, you don't need to touch this file. If you are customizing your setup, then consult the [spec/dummy/config/webpacker.yml](./spec/dummy/config/webpacker.yml) example or the official default [webpacker.yml](https://github.com/rails/webpacker/blob/master/lib/install/config/webpacker.yml).
152
+ * Configure `config/initializers/react_on_rails.rb`. You can adjust some necessary settings and defaults. See file [docs/basics/configuration.md](https://www.shakacode.com/react-on-rails/docs/basics/configuration) for documentation of all configuration options.
153
+ * Configure `config/webpacker.yml`. If you used the generator and the default webpacker setup, you don't need to touch this file. If you are customizing your setup, then consult the [spec/dummy/config/webpacker.yml](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/config/webpacker.yml) example or the official default [webpacker.yml](https://github.com/rails/webpacker/blob/master/lib/install/config/webpacker.yml).
147
154
  * Tip: set `compile: false` for development if you know that you'll always be compiling with a watch process. Otherwise, every request will check if compilation is needed.
148
155
  * Your `public_output_path` must match your custom Webpack configuration for `output` of your bundles.
149
156
  * Only set `cache_manifest` to `true` in your production env.
@@ -178,9 +185,9 @@ issue.
178
185
  # Rails View
179
186
  <%= react_component("HelloWorld", props: { name: "Stranger" }) %>
180
187
  ```
181
-
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.
183
-
188
+
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 [Render-Functions and the RailsContext](https://www.shakacode.com/react-on-rails/docs/basics/render-functions-and-railscontext) for more details on this topic.
190
+
184
191
  ```js
185
192
  import React from 'react';
186
193
 
@@ -193,9 +200,9 @@ issue.
193
200
  </div>
194
201
  );
195
202
  };
196
- ```
197
-
198
- See the [View Helpers API](./docs/api/view-helpers-api.md) for more details on `react_component` and its sibling function `react_component_hash`.
203
+ ```
204
+
205
+ See the [View Helpers API](https://www.shakacode.com/react-on-rails/docs/api/view-helpers-api) for more details on `react_component` and its sibling function `react_component_hash`.
199
206
 
200
207
  ## Globally Exposing Your React Components
201
208
 
@@ -214,7 +221,7 @@ This is how to expose a component to the `react_component` view helper.
214
221
 
215
222
  #### Different Server-Side Rendering Code (and a Server-Specific Bundle)
216
223
 
217
- You may want different code for your server-rendered components running server side versus client side. For example, if you have an animation that runs when a component is displayed, you might need to turn that off when server rendering. One way to handle this is conditional code like `if (window) { doClientOnlyCode() }`.
224
+ You may want different code for your server-rendered components running server side versus client side. For example, if you have an animation that runs when a component is displayed, you might need to turn that off when server rendering. One way to handle this is conditional code like `if (window) { doClientOnlyCode() }`.
218
225
 
219
226
  Another way is to use a separate webpack configuration file that can use a different server side entry file, like 'serverRegistration.js' as opposed to 'clientRegistration.js.' That would set up different code for server rendering.
220
227
 
@@ -224,7 +231,7 @@ For details on techniques to use different code for client and server rendering,
224
231
 
225
232
  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:
226
233
 
227
- 1. You to have access to the `railsContext`. See [documentation for the railsContext](./docs/basics/render-functions-and-railscontext.md) in terms of why you might need it. You **need** a Render-Function to access the `railsContext`.
234
+ 1. You to have access to the `railsContext`. See [documentation for the railsContext](https://www.shakacode.com/react-on-rails/docs/basics/render-functions-and-railscontext) in terms of why you might need it. You **need** a Render-Function to access the `railsContext`.
228
235
  2. You can use the passed-in props to initialize a redux store or set up react-router.
229
236
  3. You can return different components depending on what's in the props.
230
237
 
@@ -250,7 +257,7 @@ Thus, there is no difference between registering a React Function Component or c
250
257
 
251
258
  ## react_component_hash for Render-Functions
252
259
 
253
- 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`.
260
+ 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`.
254
261
 
255
262
  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:
256
263
 
@@ -258,7 +265,7 @@ For server rendering, if you wish to return multiple HTML strings from a Render-
258
265
  { renderedHtml: { componentHtml, customKey1, customKey2} }
259
266
  ```
260
267
 
261
- For details on using react_component_hash with react-helmet, see the docs below for the helper API and [docs/additional-reading/react-helmet.md](docs/additional-reading/react-helmet.md).
268
+ For details on using react_component_hash with react-helmet, see [our react-helmet documentation](https://www.shakacode.com/react-on-rails/docs/additional-reading/react-helmet).
262
269
 
263
270
  ## Error Handling
264
271
 
@@ -268,19 +275,19 @@ For details on using react_component_hash with react-helmet, see the docs below
268
275
  ## I18n
269
276
 
270
277
  React on Rails provides an option for automatic conversions of Rails `*.yml` locale files into `*.json` or `*.js*.
271
- See the [How to add I18n](docs/basics/i18n.md) for a summary of adding I18n.
278
+ See the [How to add I18n](https://www.shakacode.com/react-on-rails/docs/basics/i18n) for a summary of adding I18n.
272
279
 
273
280
  ## More Details
274
281
 
275
- Browse the links in the [Summary Table of Contents](./SUMMARY.md)
282
+ Browse the links in the [Summary Table of Contents](https://github.com/shakacode/react_on_rails/tree/master/SUMMARY.md)
276
283
 
277
284
  Here are some highly recommended next articles to read:
278
285
 
279
- 1. [How React on Rails Works](docs/outdated/how-react-on-rails-works.md)
280
- 1. [Webpack Configuration](./docs/basics/webpack-configuration.md)
281
- 1. [View Helpers API](./docs/api/view-helpers-api.md)
286
+ 1. [How React on Rails Works](https://www.shakacode.com/react-on-rails/docs/basics/how-react-on-rails-works)
287
+ 1. [Webpack Configuration](https://www.shakacode.com/react-on-rails/docs/basics/webpack-configuration)
288
+ 1. [View Helpers API](https://www.shakacode.com/react-on-rails/docs/api/view-helpers-api)
282
289
  1. [Caching and Performance: React on Rails Pro](https://www.shakacode.com/react-on-rails-pro).
283
- 1. [Deployment](docs/basics/deployment.md).
290
+ 1. [Deployment](https://www.shakacode.com/react-on-rails/docs/basics/deployment).
284
291
 
285
292
  # Support
286
293
 
@@ -296,20 +303,20 @@ Please [**click to subscribe**](https://app.mailerlite.com/webforms/landing/l1d9
296
303
  - **[forum.shakacode.com](https://forum.shakacode.com)**: Post your questions
297
304
  - **[@railsonmaui on Twitter](https://twitter.com/railsonmaui)**
298
305
  - For a live, [open source](https://github.com/shakacode/react-webpack-rails-tutorial), example of this gem, see [www.reactrails.com](http://www.reactrails.com).
299
- - See [Projects](PROJECTS.md) using and [KUDOS](./KUDOS.md) for React on Rails. Please submit yours! Please edit either page or [email us](mailto:contact@shakacode.com) and we'll add your info. We also **love stars** as it helps us attract new users and contributors.
300
- - *See [NEWS.md](NEWS.md) for more notes over time.*
306
+ - See [Projects](https://github.com/shakacode/react_on_rails/tree/master/PROJECTS.md) using and [KUDOS](https://github.com/shakacode/react_on_rails/tree/master/KUDOS.md) for React on Rails. Please submit yours! Please edit either page or [email us](mailto:contact@shakacode.com) and we'll add your info. We also **love stars** as it helps us attract new users and contributors.
307
+ - *See [NEWS.md](https://github.com/shakacode/react_on_rails/tree/master/NEWS.md) for more notes over time.*
301
308
 
302
309
  ## Contributing
303
310
 
304
- 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).
311
+ Bug reports and pull requests are welcome. See [Contributing](https://github.com/shakacode/react_on_rails/tree/master/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).
305
312
 
306
313
  ## React on Rails Pro
307
314
 
308
- 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.
315
+ Support React on Rails Pro development [by becoming a Github sponsor](https://github.com/sponsors/shakacode) and get these benefits.
309
316
 
310
- [![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)
317
+ React on Rails Pro includes 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://www.shakacode.com/blog/hvmns-90-reduction-in-server-response-time-from-react-on-rails-pro/). The [Wiki](https://github.com/shakacode/react_on_rails/wiki) contains more details.
311
318
 
312
- ## React on Rails Pro Support
319
+ [![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)
313
320
 
314
321
  The [React on Rails Pro Support Plan](https://www.shakacode.com/react-on-rails-pro) can help!
315
322
 
@@ -323,7 +330,7 @@ ShakaCode can also help you with your custom software development needs. We spec
323
330
 
324
331
  Please email Justin Gordon [justin@shakacode.com](mailto:justin@shakacode.com), the maintainer of React on Rails, for more information.
325
332
 
326
- ### Fragment Caching
333
+ ### Pro: Fragment Caching
327
334
 
328
335
  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:
329
336
 
@@ -344,16 +351,16 @@ Such fragment caching saves CPU work for your web server and greatly reduces the
344
351
  4. Creating the HTML string containing the props and the server-rendered JavaScript code.
345
352
 
346
353
  Note, even without server rendering (without step 3 above), fragment caching is still effective.
347
-
348
- ## Integration with Node.js for Server Rendering
354
+
355
+ ### Pro: Integration with Node.js for Server Rendering
349
356
 
350
357
  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).
351
358
 
352
359
  ## Testimonials for ShakaCode
353
- [HVMN Testimonial, by Paul Benigeri, October 12, 2018](./docs/testimonials/hvmn.md)
360
+ [HVMN Testimonial, by Paul Benigeri, October 12, 2018](https://www.shakacode.com/react-on-rails/docs/testimonials/hvmn)
354
361
  > 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.
355
362
 
356
- [ResortPass Testimonial, by Leora Juster, December 10, 2018](./docs/testimonials/resortpass.md)
363
+ [ResortPass Testimonial, by Leora Juster, December 10, 2018](https://www.shakacode.com/react-on-rails/docs/testimonials/resortpass)
357
364
 
358
365
  > 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.
359
366
 
@@ -361,16 +368,17 @@ From Joel Hooks, Co-Founder, Chief Nerd at [egghead.io](https://egghead.io/), Ja
361
368
 
362
369
  ![2017-01-30_11-33-59](https://cloud.githubusercontent.com/assets/1118459/22443635/b3549fb4-e6e3-11e6-8ea2-6f589dc93ed3.png)
363
370
 
364
- For more testimonials, see [Live Projects](PROJECTS.md) and [Kudos](./KUDOS.md).
371
+ For more testimonials, see [Live Projects](https://github.com/shakacode/react_on_rails/tree/master/PROJECTS.md) and [Kudos](https://github.com/shakacode/react_on_rails/tree/master/KUDOS.md).
365
372
 
366
373
  # Supporters
367
374
 
368
- 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.
375
+ 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 [HiChee.com](https://HiChee.com), [Rails AutoScale](https://railsautoscale.com) to scale the dynos of HiChee, [BrowserStack](https://www.browserstack.com) to solve problems with oddball browsers.
369
376
 
370
377
  [![2019-09-24_17-48-00](https://user-images.githubusercontent.com/1118459/65567887-96353780-def3-11e9-926d-4a55e2e186ff.png)](https://www.jetbrains.com/ruby/)
371
378
  [![Scout](https://user-images.githubusercontent.com/1118459/41828269-106b40f8-77d0-11e8-8d19-9c4b167ef9d8.png)](https://scoutapp.com/)
379
+ [![2020-12-27_21-26-19](https://user-images.githubusercontent.com/1118459/103197530-48dc0e80-488a-11eb-8b1b-a16664b30274.png)](https://railsautoscale.com/)
372
380
  [![BrowserStack](https://cloud.githubusercontent.com/assets/1118459/23203304/1261e468-f886-11e6-819e-93b1a3f17da4.png)](https://www.browserstack.com)
373
- [![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)
381
+
374
382
 
375
383
  ## Clubhouse
376
384
  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!
@@ -380,8 +388,8 @@ I've just moved ShakaCode's development to [ClubHouse](https://clubhouse.io/) fr
380
388
  Aloha and best wishes from Justin and the ShakaCode team!
381
389
 
382
390
  # Work with Us
383
- 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!
391
+ 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 [HiChee](https://hichee.com). Your main coding interview will be pairing with us on our open source! We're also using [ReasonML](https://reasonml.github.io/) extensively!
384
392
 
385
393
  # License
386
394
 
387
- The gem is available as open source under the terms of the [MIT License](LICENSE.md).
395
+ The gem is available as open source under the terms of the [MIT License](https://github.com/shakacode/react_on_rails/tree/master/LICENSE.md).