react_on_rails 11.0.5 → 13.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +338 -0
  3. data/.eslintignore +2 -1
  4. data/.eslintrc +32 -3
  5. data/.github/FUNDING.yml +1 -0
  6. data/.github/ISSUE_TEMPLATE/bug_report.md +23 -0
  7. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  8. data/.github/PULL_REQUEST_TEMPLATE.md +19 -0
  9. data/.github/workflows/lint-js-and-ruby.yml +54 -0
  10. data/.github/workflows/main.yml +183 -0
  11. data/.github/workflows/package-js-tests.yml +35 -0
  12. data/.github/workflows/rspec-package-specs.yml +46 -0
  13. data/.gitignore +3 -4
  14. data/.prettierignore +14 -0
  15. data/.prettierrc +20 -0
  16. data/.rubocop.yml +76 -34
  17. data/.travis.yml +15 -22
  18. data/CHANGELOG.md +443 -55
  19. data/CONTRIBUTING.md +62 -80
  20. data/Gemfile +1 -35
  21. data/Gemfile.development_dependencies +50 -0
  22. data/KUDOS.md +4 -1
  23. data/{docs/LICENSE.md → LICENSE.md} +1 -1
  24. data/NEWS.md +14 -4
  25. data/REACT-ON-RAILS-PRO-LICENSE +95 -0
  26. data/README.md +107 -802
  27. data/Rakefile +1 -8
  28. data/SUMMARY.md +51 -29
  29. data/book.json +5 -5
  30. data/docs/{basics/generator.md → additional-details/generator-details.md} +5 -13
  31. data/docs/{basics/installation-overview.md → additional-details/manual-installation-overview.md} +9 -14
  32. data/docs/{basics → additional-details}/migrating-from-react-rails.md +1 -1
  33. data/docs/additional-details/recommended-project-structure.md +69 -0
  34. data/docs/additional-details/tips-for-usage-with-sp6.md +15 -0
  35. data/docs/additional-details/upgrade-webpacker-v3-to-v4.md +10 -0
  36. data/docs/api/javascript-api.md +35 -6
  37. data/docs/api/redux-store-api.md +102 -0
  38. data/docs/api/view-helpers-api.md +133 -0
  39. data/docs/contributor-info/errors-with-hooks.md +45 -0
  40. data/docs/contributor-info/linters.md +5 -6
  41. data/docs/contributor-info/pull-requests.md +42 -0
  42. data/docs/contributor-info/releasing.md +1 -1
  43. data/docs/deployment/heroku-deployment.md +39 -0
  44. data/docs/getting-started.md +196 -0
  45. data/docs/guides/client-vs-server-rendering.md +27 -0
  46. data/docs/guides/configuration.md +289 -0
  47. data/docs/guides/deployment.md +5 -0
  48. data/docs/guides/file-system-based-automated-bundle-generation.md +197 -0
  49. data/docs/guides/hmr-and-hot-reloading-with-the-webpack-dev-server.md +104 -0
  50. data/docs/guides/how-react-on-rails-works.md +44 -0
  51. data/docs/guides/how-to-conditionally-server-render-based-on-device-type.md +40 -0
  52. data/docs/guides/how-to-use-different-files-for-client-and-server-rendering.md +98 -0
  53. data/docs/guides/i18n.md +87 -0
  54. data/docs/guides/installation-into-an-existing-rails-app.md +66 -0
  55. data/docs/guides/minitest-configuration.md +31 -0
  56. data/docs/guides/rails-webpacker-react-integration-options.md +213 -0
  57. data/docs/guides/react-on-rails-overview.md +29 -0
  58. data/docs/guides/react-server-rendering.md +32 -0
  59. data/docs/guides/render-functions-and-railscontext.md +205 -0
  60. data/docs/guides/rspec-configuration.md +73 -0
  61. data/docs/guides/tutorial.md +371 -0
  62. data/docs/{basics → guides}/upgrading-react-on-rails.md +126 -3
  63. data/docs/guides/webpack-configuration.md +42 -0
  64. data/docs/home.md +23 -0
  65. data/docs/javascript/asset-pipeline.md +12 -0
  66. data/docs/{additional-reading → javascript}/code-splitting.md +21 -11
  67. data/docs/javascript/converting-from-custom-webpack-config-to-rails-webpacker-config.md +10 -0
  68. data/docs/javascript/credits.md +10 -0
  69. data/docs/{additional-reading → javascript}/images.md +5 -6
  70. data/docs/javascript/react-helmet.md +100 -0
  71. data/docs/javascript/react-router.md +90 -0
  72. data/docs/{additional-reading → javascript}/server-rendering-tips.md +15 -12
  73. data/docs/javascript/troubleshooting-when-using-shakapacker.md +77 -0
  74. data/docs/{additional-reading → javascript}/webpack.md +2 -2
  75. data/docs/misc/articles.md +20 -0
  76. data/docs/misc/doctrine.md +5 -6
  77. data/docs/outdated/deferred-rendering.md +39 -0
  78. data/docs/{additional-reading → outdated}/rails-assets-relative-paths.md +4 -4
  79. data/docs/{additional-reading → outdated}/rails-assets.md +12 -20
  80. data/docs/{misc → outdated}/rails3.md +2 -2
  81. data/docs/rails/convert-rails-5-api-only-app.md +19 -0
  82. data/docs/rails/rails-engine-integration.md +32 -0
  83. data/docs/{additional-reading → rails}/rails_view_rendering_from_inline_javascript.md +2 -1
  84. data/docs/{additional-reading → rails}/turbolinks.md +13 -1
  85. data/docs/react-on-rails-pro/react-on-rails-pro.md +43 -0
  86. data/docs/testimonials/hvmn.md +25 -0
  87. data/docs/testimonials/resortpass.md +13 -0
  88. data/docs/testimonials/testimonials.md +28 -0
  89. data/jest.config.js +4 -0
  90. data/lib/generators/USAGE +1 -1
  91. data/lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb +41 -0
  92. data/lib/generators/react_on_rails/base_generator.rb +55 -43
  93. data/lib/generators/react_on_rails/bin/dev +30 -0
  94. data/lib/generators/react_on_rails/bin/dev-static +30 -0
  95. data/lib/generators/react_on_rails/dev_tests_generator.rb +4 -3
  96. data/lib/generators/react_on_rails/generator_helper.rb +8 -6
  97. data/lib/generators/react_on_rails/generator_messages.rb +40 -0
  98. data/lib/generators/react_on_rails/install_generator.rb +37 -0
  99. data/lib/generators/react_on_rails/templates/.eslintrc +3 -1
  100. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev +4 -6
  101. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-static +9 -0
  102. data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +21 -40
  103. data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css +4 -0
  104. data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorldServer.js +5 -0
  105. data/lib/generators/react_on_rails/templates/base/base/app/javascript/packs/server-bundle.js +8 -0
  106. data/lib/generators/react_on_rails/templates/base/base/app/views/layouts/hello_world.html.erb +2 -1
  107. data/lib/generators/react_on_rails/templates/base/base/babel.config.js.tt +32 -0
  108. data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +20 -4
  109. data/lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml +62 -0
  110. data/lib/generators/react_on_rails/templates/base/base/config/webpack/clientWebpackConfig.js.tt +17 -0
  111. data/lib/generators/react_on_rails/templates/base/base/config/webpack/commonWebpackConfig.js.tt +17 -0
  112. data/lib/generators/react_on_rails/templates/base/base/config/webpack/development.js.tt +25 -0
  113. data/lib/generators/react_on_rails/templates/base/base/config/webpack/production.js.tt +9 -0
  114. data/lib/generators/react_on_rails/templates/base/base/config/webpack/serverWebpackConfig.js.tt +117 -0
  115. data/lib/generators/react_on_rails/templates/base/base/config/webpack/test.js.tt +9 -0
  116. data/lib/generators/react_on_rails/templates/base/base/config/webpack/webpack.config.js.tt +15 -0
  117. data/lib/generators/react_on_rails/templates/base/base/config/webpack/webpackConfig.js.tt +36 -0
  118. data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +8 -2
  119. data/lib/generators/react_on_rails/templates/dev_tests/spec/simplecov_helper.rb +1 -1
  120. data/lib/generators/react_on_rails/templates/dev_tests/spec/{features → system}/hello_world_spec.rb +2 -2
  121. data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +6 -9
  122. data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/store/helloWorldStore.js +1 -3
  123. data/lib/react_on_rails/configuration.rb +198 -145
  124. data/lib/react_on_rails/error.rb +2 -0
  125. data/lib/react_on_rails/git_utils.rb +5 -3
  126. data/lib/react_on_rails/{react_on_rails_helper.rb → helper.rb} +201 -190
  127. data/lib/react_on_rails/json_output.rb +1 -1
  128. data/lib/react_on_rails/json_parse_error.rb +28 -0
  129. data/lib/react_on_rails/locales/base.rb +169 -0
  130. data/lib/react_on_rails/locales/to_js.rb +33 -0
  131. data/lib/react_on_rails/locales/to_json.rb +23 -0
  132. data/lib/react_on_rails/packs_generator.rb +234 -0
  133. data/lib/react_on_rails/prerender_error.rb +35 -27
  134. data/lib/react_on_rails/react_component/render_options.rb +64 -9
  135. data/lib/react_on_rails/server_rendering_js_code.rb +55 -0
  136. data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +126 -76
  137. data/lib/react_on_rails/server_rendering_pool.rb +0 -1
  138. data/lib/react_on_rails/test_helper/ensure_assets_compiled.rb +9 -8
  139. data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +17 -0
  140. data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +13 -12
  141. data/lib/react_on_rails/test_helper.rb +24 -3
  142. data/lib/react_on_rails/utils.rb +94 -25
  143. data/lib/react_on_rails/version.rb +1 -1
  144. data/lib/react_on_rails/version_checker.rb +5 -1
  145. data/lib/react_on_rails/version_syntax_converter.rb +14 -12
  146. data/lib/react_on_rails/webpacker_utils.rb +105 -5
  147. data/lib/react_on_rails.rb +8 -2
  148. data/lib/tasks/assets.rake +28 -60
  149. data/lib/tasks/generate_packs.rake +11 -0
  150. data/lib/tasks/locale.rake +5 -4
  151. data/package-scripts.yml +49 -0
  152. data/package.json +52 -47
  153. data/rakelib/docker.rake +0 -5
  154. data/rakelib/dummy_apps.rake +5 -8
  155. data/rakelib/example_type.rb +12 -3
  156. data/rakelib/examples.rake +5 -4
  157. data/rakelib/lint.rake +5 -16
  158. data/rakelib/node_package.rake +2 -2
  159. data/rakelib/release.rake +37 -23
  160. data/rakelib/run_rspec.rake +16 -44
  161. data/rakelib/task_helpers.rb +16 -4
  162. data/react_on_rails.gemspec +6 -22
  163. data/tsconfig.json +14 -0
  164. data/webpackConfigLoader.js +5 -4
  165. data/yarn.lock +5935 -3106
  166. metadata +122 -272
  167. data/Gemfile.rails32 +0 -74
  168. data/docs/additional-reading/asset-pipeline.md +0 -20
  169. data/docs/additional-reading/babel.md +0 -5
  170. data/docs/additional-reading/caching-and-performance.md +0 -4
  171. data/docs/additional-reading/heroku-deployment.md +0 -92
  172. data/docs/additional-reading/hot-reloading-rails-development.md +0 -57
  173. data/docs/additional-reading/node-server-rendering.md +0 -5
  174. data/docs/additional-reading/rails-engine-integration.md +0 -34
  175. data/docs/additional-reading/react-helmet.md +0 -80
  176. data/docs/additional-reading/react-router.md +0 -113
  177. data/docs/additional-reading/recommended-project-structure.md +0 -49
  178. data/docs/additional-reading/rspec-configuration.md +0 -56
  179. data/docs/additional-reading/webpack-dev-server.md +0 -15
  180. data/docs/api/ruby-api-hot-reload-view-helpers.md +0 -44
  181. data/docs/api/ruby-api.md +0 -8
  182. data/docs/basics/configuration.md +0 -163
  183. data/docs/basics/i18n.md +0 -77
  184. data/docs/tutorial.md +0 -220
  185. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-server +0 -12
  186. data/lib/react_on_rails/assets_precompile.rb +0 -150
  187. data/lib/react_on_rails/locales_to_js.rb +0 -134
  188. data/ruby-lint.yml +0 -25
  189. /data/docs/{additional-reading → additional-details}/updating-dependencies.md +0 -0
  190. /data/docs/{additional-reading → deployment}/elastic-beanstalk.md +0 -0
  191. /data/docs/{additional-reading → javascript}/angular-js-integration-migration.md +0 -0
  192. /data/docs/{additional-reading → javascript}/capistrano-deployment.md +0 -0
  193. /data/docs/{additional-reading → javascript}/foreman-issues.md +0 -0
  194. /data/docs/{additional-reading → javascript}/node-dependencies-and-npm.md +0 -0
  195. /data/docs/{additional-reading → javascript}/react-and-redux.md +0 -0
  196. /data/docs/{additional-reading → javascript}/troubleshooting-when-using-webpacker.md +0 -0
  197. /data/docs/{additional-reading → javascript}/webpack-v1-notes.md +0 -0
  198. /data/docs/{coding-style → misc}/style.md +0 -0
  199. /data/docs/{additional-reading → misc}/tips.md +0 -0
data/README.md CHANGED
@@ -1,832 +1,137 @@
1
- [![Build Status](https://travis-ci.org/shakacode/react_on_rails.svg?branch=master)](https://travis-ci.org/shakacode/react_on_rails) [![Codeship Status for shakacode/react_on_rails](https://app.codeship.com/projects/cec6c040-971f-0134-488f-0a5146246bd8/status?branch=master)](https://app.codeship.com/projects/187011) [![Dependency Status](https://gemnasium.com/shakacode/react_on_rails.svg)](https://gemnasium.com/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)
1
+ ![reactrails](https://user-images.githubusercontent.com/10421828/79436261-52159b80-7fd9-11ea-994e-2a98dd43e540.png)
2
2
 
3
- *If this projects helps you, please give us a star!*
4
-
5
- ## Need Help with Rails + Webpack + React? Want better performance?
6
- Aloha, I'm Justin Gordon the creator and maintainer of React on Rails. I offer a [React on Rails Pro Support Plan](http://www.shakacode.com/work/shakacode-pro-support.pdf), and I can help you with:
7
- * Optimizing your webpack setup for React on Rails.
8
- * Upgrading from older React on Rails to newer versions.
9
- * Better performance client and server side.
10
- * Migrating from Angular to React.
11
- * Best practices based on 4 years of React on Rails experience.
12
- * Early access to the React on Rails Pro Gem and Node code, including:
13
- * ShakaCode's Node.js rendering server for better performance for server rendering (used now at [egghead.io](https://egghead.io/)).
14
- * Performance helpers, especially for server rendering
15
- * Webpack configuration examples
16
-
17
- Please [email me](mailto:justin@shakacode.com) for a free half-hour project consultation, on anything from React on Rails to any aspect of web development.
18
-
19
- ----
20
-
21
- ## React on Rails is based on Webpacker!
22
-
23
- Given that Webpacker already provides React integration, why would you use "React on Rails"? Additional features of React on Rails include:
24
-
25
- 1. Server rendering, often for SEO optimization.
26
- 2. 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.
27
- 3. Redux and React-Router integration
28
- 4. Localization support
29
- 5. Rspec test helpers to ensure your Webpack bundles are ready for tests
30
- 6. A supportive community
31
-
32
- ----
33
-
34
- ## Steps to a New App with rails/webpacker v3 plus latest React on Rails:
35
- First be sure to run `rails -v` and check that you are using Rails 5.1.3 or above. If you are using an older version of Rails, you'll need to install webpacker with React per the instructions [here](https://github.com/rails/webpacker).
36
-
37
- ### Basic installation for a new Rails App
38
- *See below for steps on an existing Rails app*
39
-
40
- 1. New Rails app: `rails new my-app --webpack=react`. `cd` into the directory.
41
- 2. Add gem version: `gem 'react_on_rails', '11.0.0' # Use the exact gem version to match npm version`
42
- 3. `bundle install`
43
- 4. Commit this to git (or else you cannot run the generator unless you pass the option --ignore-warnings).
44
- 5. Run the generator: `rails generate react_on_rails:install`
45
- 6. Start the app: `rails s`
46
- 7. Visit http://localhost:3000/hello_world
47
-
48
- ### Turn on server rendering
49
-
50
- 1. Edit `app/views/hello_world/index.html.erb` and set `prerender` to `true`.
51
- 2. Refresh the page.
52
-
53
- This is the line where you turn server rendering on by setting prerender to true:
54
-
55
- ```
56
- <%= react_component("HelloWorld", props: @hello_world_props, prerender: false) %>
57
- ```
58
-
59
- -----
60
-
61
- # Community Resources
62
- Please [**click to subscribe**](https://app.mailerlite.com/webforms/landing/l1d9x5) to keep in touch with Justin Gordon and [ShakaCode](http://www.shakacode.com/). I intend to send announcements of new releases of React on Rails and of our latest [blog articles](https://blog.shakacode.com) and tutorials. Subscribers will also have access to **exclusive content**, including tips and examples.
63
-
64
- [![2017-01-31_14-16-56](https://cloud.githubusercontent.com/assets/1118459/22490211/f7a70418-e7bf-11e6-9bef-b3ccd715dbf8.png)](https://app.mailerlite.com/webforms/landing/l1d9x5)
65
-
66
- * **Slack Room**: [Contact us](mailto:contact@shakacode.com) for an invite to the ShakaCode Slack room! Let us know if you want to contribute.
67
- * **[forum.shakacode.com](https://forum.shakacode.com)**: Post your questions
68
- * **[@railsonmaui on Twitter](https://twitter.com/railsonmaui)**
69
- * 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).
70
- * 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.
71
- * *See [NEWS.md](NEWS.md) for more notes over time.*
72
-
73
- ------
74
-
75
- # Testimonials
76
- From Joel Hooks, Co-Founder, Chief Nerd at [egghead.io](https://egghead.io/), January 30, 2017:
77
-
78
- ![2017-01-30_11-33-59](https://cloud.githubusercontent.com/assets/1118459/22443635/b3549fb4-e6e3-11e6-8ea2-6f589dc93ed3.png)
79
-
80
- For more testimonials, see [Live Projects](PROJECTS.md) and [Kudos](./KUDOS.md).
81
-
82
- -------
83
-
84
- # Articles, Videos, and Podcasts
85
-
86
- ### Articles
87
- * [Introducing React on Rails v9 with Webpacker Support](https://blog.shakacode.com/introducing-react-on-rails-v9-with-webpacker-support-f2584c6c8fa4) for an overview of the integration of React on Rails with Webpacker.
88
- * [Webpacker Lite: Why Fork Webpacker?](https://blog.shakacode.com/webpacker-lite-why-fork-webpacker-f0a7707fac92)
89
- * [React on Rails, 2000+ 🌟 Stars](https://medium.com/shakacode/react-on-rails-2000-stars-32ff5cfacfbf#.6gmfb2gpy)
90
- * [The React on Rails Doctrine](https://medium.com/@railsonmaui/the-react-on-rails-doctrine-3c59a778c724)
91
- * [Simple Tutorial](https://github.com/shakacode/react_on_rails/blob/master/docs/tutorial.md).
92
-
93
- ### Videos
94
- * [Video of running the v9 installer with Webpacker v3](https://youtu.be/M0WUM_XPaII). History, motivations, philosophy, and overview.
95
- 1. [GORUCO 2017: Front-End Sadness to Happiness: The React on Rails Story by Justin Gordon](https://www.youtube.com/watch?v=SGkTvKRPYrk)
96
- 1. [egghead.io: Creating a component with React on Rails](https://egghead.io/lessons/react-creating-a-component-with-react-on-rails)
97
- 1. [egghead.io: Creating a redux component with React on Rails](https://egghead.io/lessons/react-add-redux-state-management-to-a-react-on-rails-project)
98
- 1. [React On Rails Tutorial Series](https://www.youtube.com/playlist?list=PL5VAKH-U1M6dj84BApfUtvBjvF-0-JfEU)
99
- 1. [History and Motivation](https://youtu.be/F4oymbUHvoY)
100
- 1. [Basic Tutorial Walkthrough](https://youtu.be/_bjScw60FBk)
101
- 1. [Code Walkthrough](https://youtu.be/McQ9UM-_ocQ)
102
-
103
- ------
104
-
105
- # React on Rails
106
-
107
- **Project Objective**: To provide an opinionated and optimal framework for integrating Ruby on Rails with React via the [**Webpacker**](https://github.com/rails/webpacker) gem.
108
-
109
- React on Rails integrates Facebook's [React](https://github.com/facebook/react) front-end framework with Rails. React v0.14.x and greater is supported, with server rendering. [Redux](https://github.com/reactjs/redux) and [React-Router](https://github.com/reactjs/react-router) are supported as well, also with server rendering, using **execJS**.
110
-
111
- The ability to use a standalone Node Rendering server for better performance and tooling is supported for React on Rails Pro. Contact [justin@shakacode.com](mailto:justin@shakacode.com) for more information.
112
-
113
- ## Table of Contents
114
-
115
- + [Features](#features)
116
- + [Why Webpack?](#why-webpack)
117
- + [rails/webpacker or custom setup for Webpack?](#webpack-configuration-custom-setup-for-webpack-or-railswebpacker)
118
- + [Getting Started with an existing Rails app](#getting-started-with-an-existing-rails-app)
119
- - [Installation Overview](#installation-overview)
120
- - [Initializer Configuration: config/initializers/react_on_rails.rb](#initializer-configuration)
121
- - [Including your React Component in your Rails Views](#including-your-react-component-in-your-rails-views)
122
- - [I18n](#i18n)
123
- - [Convert rails-5 API only app to rails app](#convert-rails-5-api-only-app-to-rails-app)
124
- - [NPM](#npm)
125
- - [Webpacker Configuration](#webpacker-configuration)
126
- + [How it Works](#how-it-works)
127
- - [Client-Side Rendering vs. Server-Side Rendering](#client-side-rendering-vs-server-side-rendering)
128
- - [Building the Bundles](#building-the-bundles)
129
- - [Rails Context and Generator Functions](#rails-context-and-generator-functions)
130
- - [Globally Exposing Your React Components](#globally-exposing-your-react-components)
131
- - [ReactOnRails View Helpers API](#reactonrails-view-helpers-api)
132
- - [ReactOnRails JavaScript API](#reactonrails-javascript-api)
133
- - [React-Router](#react-router)
134
- - [Deployment](#deployment)
135
- + [Integration with Node.js for Server Rendering](#integration-with-nodejs-for-server-rendering)
136
- + [Additional Documentation](#additional-documentation)
137
- + [Contributing](#contributing)
138
- + [License](#license)
139
- + [Authors](#authors)
140
- + [About ShakaCode](#about-shakacode)
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://www.shakacode.com/react-on-rails-pro"><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>
141
9
 
142
10
  ---
143
11
 
144
- ## Features
145
- Like the [react-rails](https://github.com/reactjs/react-rails) gem, React on Rails is capable of server-side rendering with fragment caching and is compatible with [turbolinks](https://github.com/turbolinks/turbolinks). While the initial setup is slightly more involved, it allows for advanced functionality such as:
146
-
147
- + [Redux](https://github.com/reactjs/redux)
148
- + [Webpack optimization functionality](https://github.com/webpack/docs/wiki/optimization)
149
- + [React Router](https://github.com/reactjs/react-router)
150
-
151
- See the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial) for an example of a live implementation and code.
152
-
153
- ## Why Webpack?
154
-
155
- Webpack is used to generate JavaScript and CSS "bundles" directly to your `/public` directory. [webpacker](https://github.com/rails/webpacker) provides view helpers to access the Webpack generated (and fingerprinted) JS and CSS. These files totally skip the Rails asset pipeline. You are responsible for properly processing your Webpack output via the Webpack config files.
156
-
157
- This usage of webpack fits neatly and simply into existing Rails apps. You can include React components on a Rails view with a simple helper.
158
-
159
- Compare this to some alternative approaches for SPAs (Single Page Apps) that utilize Webpack and Rails. They will use a separate node server to distribute web pages, JavaScript assets, CSS, etc., and will still use Rails as an API server. A good example of this is our ShakaCode team member Alex's article [
160
- Universal React with Rails: Part I](https://medium.com/@alexfedoseev/isomorphic-react-with-rails-part-i-440754e82a59).
161
-
162
- ## Webpack Configuration: custom setup for Webpack or rails/webpacker?
163
-
164
- Version 9 of React on Rails added support for the rails/webpacker view helpers so that Webpack produced assets would no longer pass through the Rails asset pipeline. As part of this change, React on Rails added a configuration option to support customization of the node_modules directory. This allowed React on Rails to support the rails/webpacker configuration of the Webpack configuration.
165
-
166
- A key decision in your use React on Rails is whether you go with the rails/webpacker default setup or the traditional React on Rails setup of putting all your client side files under the `/client` directory. While there are technically 2 independent choices involved, the directory structure and the mechanism of Webpack configuration, for simplicity sake we'll assume that these choices go together.
167
-
168
- ### Traditional React on Rails using the /client directory
169
-
170
- Until version 9, all React on Rails apps used the `/client` directory for configuring React on Rails in terms of the configuration of Webpack and location of your JavaScript and Webpack files, including the node_modules directory. Version 9 changed the default to `/` for the `node_modules` location using this value in `config/initializers/react_on_rails.rb`: `config.node_modules_location`.
171
-
172
- The [ShakaCode Team](http://www.shakacode.com) _recommends_ this approach for projects beyond the simplest cases as it provides the greatest transparency in your webpack and overall client-side setup. The *big advantage* to this is that almost everything within the `/client` directory will apply if you wish to convert your client-side code to a pure Single Page Application that runs without Rails. This allows you to google for how to do something with Webpack configuration and what applies to a non-Rails app will apply just as well to a React on Rails app.
173
-
174
- The two best examples of this patten are the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial) and the integration test example in [spec/dummy](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy).
175
-
176
- In this case, you don't need to understand the nuances of customization of your Wepback config via the [Webpacker mechanism](https://github.com/rails/webpacker/blob/master/docs/webpack.md).
177
-
178
-
179
- ### rails/webpacker Setup
180
-
181
- Typical rails/webpacker apps have a standard directory structure as documented [here](https://github.com/rails/webpacker/blob/master/docs/folder-structure.md). If you follow the steps in the the [basic tutorial](https://github.com/shakacode/react_on_rails/blob/master/docs/tutorial.md), you will see this pattern in action. In order to customize the Webpack configuration, you need to consult with the [rails/webpacker Webpack configuration](https://github.com/rails/webpacker/blob/master/docs/webpack.md).
182
-
183
- Version 9 made this the default for generated apps for 2 reasons:
184
-
185
- 1. It's less code to generate and thus less to explain.
186
- 2. `rails/webpacker` might be viewed as a convention in the Rails community.
187
-
188
- The *advantage* of this is that there is very little code needed to get started and you don't need to understand really anything about Webpack customization. The *big disadvantage* to this is that you will need to learn the ins and outs of the [rails/webpacker way to customize Webpack](https://github.com/rails/webpacker/blob/master/docs/webpack.md) which differs from the plain [Webpack way](https://webpack.js.org/).
189
-
190
- Overall, consider carefully if you prefer the `rails/webpacker` directory structure and Webpack configuration, over the placement of all client side files within the `/client` directory along with conventional Webpack configuration.
191
-
192
- See [Issue 982: Tutorial Generating Correct Project Structure?](https://github.com/shakacode/react_on_rails/issues/982) to discuss this issue.
193
-
194
-
195
- ## Getting Started with an existing Rails app
196
-
197
- **For more detailed instructions on a fresh Rails app**, see the [React on Rails Basic Tutorial](docs/tutorial.md).
198
-
199
- **If you have rails-5 API only project**, first [convert the rails-5 API only app to rails app](#convert-rails-5-api-only-app-to-rails-app) before [getting started](#getting-started-with-an-existing-rails-app).
200
- 1. Add the following to your Gemfile and `bundle install`. We recommend fixing the version of React on Rails, as you will need to keep the exact version in sync with the version in your `client/package.json` file.
201
-
202
- ```ruby
203
- gem "react_on_rails", "11.0.0"
204
- gem "webpacker", "~> 3.0"
205
- ```
206
-
207
- 2. Run the following 2 commands to install Webpacker with React:
208
- ```
209
- bundle exec rails webpacker:install
210
- bundle exec rails webpacker:install:react
211
-
212
- ```
213
-
214
- 2. Commit this to git (or else you cannot run the generator unless you pass the option `--ignore-warnings`).
215
-
216
- 3. See help for the generator:
217
-
218
- ```bash
219
- rails generate react_on_rails:install --help
220
- ```
221
-
222
- 4. Run the generator with a simple "Hello World" example (more options below):
223
-
224
- ```bash
225
- rails generate react_on_rails:install
226
- ```
227
-
228
- 5. Ensure that you have `foreman` installed: `gem install foreman`.
229
-
230
- 7. Start your Rails server:
231
-
232
- ```bash
233
- foreman start -f Procfile.dev
234
- ```
235
-
236
- 8. Visit [localhost:3000/hello_world](http://localhost:3000/hello_world). Note: `foreman` defaults to PORT 5000 unless you set the value of PORT in your environment. For example, you can `export PORT=3000` to use the Rails default port of 3000. For the hello_world example this is already set.
237
-
238
- ### Installation Overview
239
-
240
- See the [Installation Overview](docs/basics/installation-overview.md) for a concise set summary of what's in a React on Rails installation.
241
-
242
- ### Initializer Configuration
243
-
244
- Configure the file `config/initializers/react_on_rails.rb`. You can adjust some necessary settings and defaults. See file [docs/basics/configuration.md](https://github.com/shakacode/react_on_rails/tree/master/docs/basics/configuration.md) for documentation of all configuration options.
245
-
246
- ### Including your React Component in your Rails Views
247
-
248
- + *Normal Mode (React component will be rendered on client):*
249
-
250
- ```erb
251
- <%= react_component("HelloWorld", props: @some_props) %>
252
- ```
253
- + *Server-Side Rendering (React component is first rendered into HTML on the server):*
254
-
255
- ```erb
256
- <%= react_component("HelloWorld", props: @some_props, prerender: true) %>
257
- ```
258
-
259
- + The `component_name` parameter is a string matching the name you used to expose your React component globally. So, in the above examples, if you had a React component named "HelloWorld", you would register it with the following lines:
260
-
261
- ```js
262
- import ReactOnRails from 'react-on-rails';
263
- import HelloWorld from './HelloWorld';
264
- ReactOnRails.register({ HelloWorld });
265
- ```
266
-
267
- Exposing your component in this way is how React on Rails is able to reference your component from a Rails view. You can expose as many components as you like, as long as their names do not collide. See below for the details of how you expose your components via the react_on_rails webpack configuration.
268
-
269
- + `@some_props` can be either a hash or JSON string. This is an optional argument assuming you do not need to pass any options (if you want to pass options, such as `prerender: true`, but you do not want to pass any properties, simply pass an empty hash `{}`). This will make the data available in your component:
270
-
271
- ```ruby
272
- # Rails View
273
- <%= react_component("HelloWorld", props: { name: "Stranger" }) %>
274
- ```
275
-
276
- ```javascript
277
- // inside your React component
278
- this.props.name // "Stranger"
279
- ```
280
-
281
- ### I18n
282
-
283
- You can enable the i18n functionality with [react-intl](https://github.com/yahoo/react-intl).
284
-
285
- React on Rails provides an option for automatic conversions of Rails `*.yml` locale files into `*.js` files for `react-intl`.
286
-
287
- See the [How to add I18n](docs/basics/i18n.md) for a summary of adding I18n.
288
-
289
- ### Convert rails-5 API only app to rails app
290
-
291
- 1. Go to the directory where you created your app
12
+ [![License](https://img.shields.io/badge/license-mit-green.svg)](LICENSE.md)[![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)
292
13
 
293
- ```
294
- rails new your-current-app-name
295
- ```
14
+ [![Build Main](https://github.com/shakacode/react_on_rails/actions/workflows/main.yml/badge.svg)](https://github.com/shakacode/react_on_rails/actions/workflows/main.yml)
15
+ [![Build JS Tests](https://github.com/shakacode/react_on_rails/actions/workflows/package-js-tests.yml/badge.svg)](https://github.com/shakacode/react_on_rails/actions/workflows/package-js-tests.yml)
16
+ [![Build Rspec Tests](https://github.com/shakacode/react_on_rails/actions/workflows/rspec-package-specs.yml/badge.svg)](https://github.com/shakacode/react_on_rails/actions/workflows/rspec-package-specs.yml)
17
+ [![Linting](https://github.com/shakacode/react_on_rails/actions/workflows/lint-js-and-ruby.yml/badge.svg)](https://github.com/shakacode/react_on_rails/actions/workflows/lint-js-and-ruby.yml)
296
18
 
297
- Rails will start creating the app and will skip the files you have already created. If there is some conflict then it will stop and you need to resolve it manually. be careful at this step as it might replace you current code in conflicted files.
19
+ # News
20
+ * ShakaCode now maintains the official successor to `rails/webpacker`, [`shakapacker`](https://github.com/shakacode/shakapacker).
21
+ * Project is updated to support Rails 7 and Shakapacker v6+!
298
22
 
299
- 2. Resolve conflicts
300
-
301
- ```
302
- 1. Press "d" to see the difference
303
- 2. If it is only adding lines then press "y" to continue
304
- 3. If it is removeing some of your code then press "n" and add all additions manually
305
- ```
306
-
307
- 3. Run `bundle install` and follow [Getting started](#getting-started-with-an-existing-rails-app)
308
-
309
-
310
- ### NPM
311
- All JavaScript in React On Rails is loaded from npm: [react-on-rails](https://www.npmjs.com/package/react-on-rails). To manually install this (you did not use the generator), assuming you have a standard configuration, run this command (assuming you are in the directory where you have your `node_modules`):
312
-
313
- ```bash
314
- yarn add react-on-rails --exact
315
- ```
316
-
317
- That will install the latest version and update your package.json. **NOTE:** the `--exact` flag will ensure that you do not have a "~" or "^" for your react-on-rails version in your package.json.
318
-
319
- ### Webpacker Configuration
320
-
321
- React on Rails users should set configuration value `compile` to false, as React on Rails handles compilation for test and production environments.
322
-
323
- ## How it Works
324
- The generator installs your webpack files in the `client` folder. Foreman uses webpack to compile your code and output the bundled results to `app/assets/webpack`, which are then loaded by sprockets. These generated bundle files have been added to your `.gitignore` for your convenience.
325
-
326
- Inside your Rails views, you can now use the `react_component` helper method provided by React on Rails. You can pass props directly to the react component helper. You can also initialize a Redux store with view or controller helper `redux_store` so that the store can be shared amongst multiple React components. See the docs for `redux_store` below and scan the code inside of the [/spec/dummy](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy) sample app.
327
-
328
- ### Client-Side Rendering vs. Server-Side Rendering
329
- In most cases, you should use the `prerender: false` (default behavior) with the provided helper method to render the React component from your Rails views. In some cases, such as when SEO is vital, or many users will not have JavaScript enabled, you can enable server-rendering by passing `prerender: true` to your helper, or you can simply change the default in `config/initializers/react_on_rails`.
330
-
331
- Now the server will interpret your JavaScript using [ExecJS](https://github.com/rails/execjs) and pass the resulting HTML to the client. We recommend using [mini_racer](https://github.com/discourse/mini_racer) as ExecJS's runtime. The generator will automatically add it to your Gemfile for you (once we complete [#501](https://github.com/shakacode/react_on_rails/issues/501)).
332
-
333
- If you open the HTML source of any web page using React on Rails, you'll see the 3 parts of React on Rails rendering:
334
-
335
- 1. A script tag containing the properties of the React component, such as the registered name and any props. A JavaScript function runs after the page loads, using this data to build and initialize your React components.
336
- 2. The wrapper div `<div id="HelloWorld-react-component-0">` specifies the div where to place the React rendering. It encloses the server-rendered HTML for the React component.
337
- 3. Additional JavaScript is placed to console-log any messages, such as server rendering errors. Note: these server side logs can be configured only to be sent to the server logs.
338
-
339
- **Note**:
340
-
341
- * If server rendering is not used (prerender: false), then the major difference is that the HTML rendered for the React component only contains the outer div: `<div id="HelloWorld-react-component-0"/>`. The first specification of the React component is just the same.
342
-
343
- ### Building the Bundles
344
- Each time you change your client code, you will need to re-generate the bundles (the webpack-created JavaScript files included in application.js). The included Foreman `Procfile.dev` will take care of this for you by starting a webpack process with the watch flag. This will watch your JavaScript code files for changes. Simply run `foreman start -f Procfile.dev`.
345
-
346
- On production deployments that use asset precompilation, such as Heroku deployments, React on Rails, by default, will automatically run webpack to build your JavaScript bundles. You can see the source code for what gets added to your precompilation [here](https://github.com/shakacode/react_on_rails/tree/master/lib/tasks/assets.rake). For more information on this topic, see [the doc on Heroku deployment](./docs/additional-reading/heroku-deployment.md#more-details-on-precompilation-using-webpack-to-create-javascript-assets).
347
-
348
- If you have used the provided generator, these bundles will automatically be added to your `.gitignore` to prevent extraneous noise from re-generated code in your pull requests. You will want to do this manually if you do not use the provided generator.
349
-
350
-
351
- ### Generator Functions
352
- You have 2 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. Creating a function has the following benefits:
353
-
354
- 1. You have access to the `railsContext`. See documentation for the railsContext in terms of why you might need it. You **need** a generator function to access the `railsContext`.
355
- 1. You can use the passed-in props to initialize a redux store or set up react-router.
356
- 1. You can return different components depending on what's in the props.
357
-
358
- ReactOnRails will automatically detect a registered generator function. Thus, there is no difference between registering a React Component versus a "generator function."
359
-
360
- #### react_component_hash for Generator Functions
361
- Another reason to use a generator 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`.
362
-
363
- For server rendering, if you wish to return multiple HTML strings from a generator function, you may return an Object from your generator 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:
364
-
365
- ```js
366
- { renderedHtml: { componentHtml, customKey1, customKey2} }
367
- ```
368
-
369
- 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).
370
-
371
- ### Rails Context and Generator Functions
372
- When you use a "generator function" to create react components (or renderedHtml on the server), or you used shared redux stores, you get two params passed to your function that creates a React component:
373
-
374
- 1. `props`: Props that you pass in the view helper of either `react_component` or `redux_store`
375
- 2. `railsContext`: Rails contextual information, such as the current pathname. You can customize this in your config file. **Note**: The `railsContext` is not related to the concept of a ["context" for React components](https://facebook.github.io/react/docs/context.html#how-to-use-context).
376
-
377
- This parameters (`props` and `railsContext`) will be the same regardless of either client or server side rendering, except for the key `serverSide` based on whether or not you are server rendering.
378
-
379
- While you could manually configure your Rails code to pass the "`railsContext` information" with the rest of your "props", the `railsContext` is a convenience because it's passed consistently to all invocations of generator functions.
380
-
381
- For example, suppose you create a "generator function" called MyAppComponent.
382
-
383
- ```js
384
- import React from 'react';
385
- const MyAppComponent = (props, railsContext) => (
386
- <div>
387
- <p>props are: {JSON.stringify(props)}</p>
388
- <p>railsContext is: {JSON.stringify(railsContext)}
389
- </p>
390
- </div>
391
- );
392
- export default MyAppComponent;
393
- ```
394
-
395
- *Note: you will get a React browser console warning if you try to serverRender this since the value of `serverSide` will be different for server rendering.*
396
-
397
- So if you register your generator function `MyAppComponent`, it will get called like:
398
-
399
- ```js
400
- reactComponent = MyAppComponent(props, railsContext);
401
- ```
402
-
403
- and, similarly, any redux store always initialized with 2 parameters:
404
-
405
- ```js
406
- reduxStore = MyReduxStore(props, railsContext);
407
- ```
408
-
409
- Note: you never make these calls. React on Rails makes these calls when it does either client or server rendering. You will define functions that take these 2 params and return a React component or a Redux Store. Naturally, you do not have to use second parameter of the railsContext if you do not need it.
410
-
411
- (Note: see below [section](#multiple-react-components-on-a-page-with-one-store) on how to setup redux stores that allow multiple components to talk to the same store.)
412
-
413
- The `railsContext` has: (see implementation in file [react_on_rails_helper.rb](https://github.com/shakacode/react_on_rails/tree/master/app/helpers/react_on_rails_helper.rb), method `rails_context` for the definitive list).
414
-
415
- ```ruby
416
- {
417
- railsEnv: Rails.env
418
- # URL settings
419
- href: request.original_url,
420
- location: "#{uri.path}#{uri.query.present? ? "?#{uri.query}": ""}",
421
- scheme: uri.scheme, # http
422
- host: uri.host, # foo.com
423
- port: uri.port,
424
- pathname: uri.path, # /posts
425
- search: uri.query, # id=30&limit=5
426
-
427
- # Other
428
- serverSide: boolean # Are we being called on the server or client? Note: if you conditionally
429
- # render something different on the server than the client, then React will only show the
430
- # server version!
431
- }
432
- ```
433
-
434
- #### Why the railsContext is only passed to generator functions
435
- There's no reason that the railsContext would ever get passed to your React component unless the value is explicitly put into the props used for rendering. If you create a react component, rather than a generator function, for use by React on Rails, then you get whatever props are passed in from the view helper, which **does not include the Rails Context**. It's trivial to wrap your component in a "generator function" to return a new component that takes both:
436
-
437
- ```js
438
- import React from 'react';
439
- import AppComponent from './AppComponent';
440
- const AppComponentWithRailsContext = (props, railsContext) => (
441
- <AppComponent {...{...props, railsContext}}/>
442
- )
443
- export default AppComponentWithRailsContext;
444
- ```
445
-
446
- Consider this line in depth:
447
-
448
- ```js
449
- <AppComponent {...{ ...props, railsContext }}/>
450
- ```
451
-
452
- The outer `{...` is for the [JSX spread operator for attributes](https://facebook.github.io/react/docs/jsx-in-depth.html#spread-attributes) and the innner `{...` is for the [Spread in object literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator#Spread_in_object_literals).
453
-
454
- #### Use Cases
455
- ##### Heroku Preboot Considerations
456
- [Heroku Preboot](https://devcenter.heroku.com/articles/preboot) is a feature on Heroku that allows for faster deploy times. When you promote your staging app to production, Preboot simply switches the production server to point at the staging app's container. This means it can deploy much faster since it doesn't have to rebuild anything. However, this means that if you use the [Define Plugin](https://github.com/webpack/docs/wiki/list-of-plugins#defineplugin) to provide the rails environment to your client code as a variable, that variable will erroneously still have a value of `Staging` instead of `Production`. The `Rails.env` provided at runtime in the railsContext is, however, accurate.
457
-
458
- ##### Needing the current URL path for server rendering
459
- Suppose you want to display a nav bar with the current navigation link highlighted by the URL. When you server-render the code, your code will need to know the current URL/path. The new `railsContext` has this information. Your application will apply something like an "active" class on the server rendering.
460
-
461
- ##### Configuring different code for server side rendering
462
- Suppose you want to turn off animation when doing server side rendering. The `serverSide` value is just what you need.
463
-
464
- #### Customization of the rails_context
465
- You can customize the values passed in the `railsContext` in your `config/initializers/react_on_rails.rb`. Here's how.
466
-
467
- Set the config value for the `rendering_extension`:
468
-
469
- ```ruby
470
- config.rendering_extension = RenderingExtension
471
- ```
472
-
473
- Implement it like this above in the same file. Create a class method on the module called `custom_context` that takes the `view_context` for a param.
474
-
475
- See [spec/dummy/config/initializers/react_on_rails.rb](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/config/initializers/react_on_rails.rb) for a detailed example.
476
-
477
- ```ruby
478
- module RenderingExtension
479
-
480
- # Return a Hash that contains custom values from the view context that will get merged with
481
- # the standard rails_context values and passed to all calls to generator functions used by the
482
- # react_component and redux_store view helpers
483
- def self.custom_context(view_context)
484
- {
485
- somethingUseful: view_context.session[:something_useful]
486
- }
487
- end
488
- end
489
- ```
490
-
491
- In this case, a prop and value for `somethingUseful` will go into the railsContext passed to all react_component and redux_store calls. You may set any values available in the view rendering context.
492
-
493
- ### Globally Exposing Your React Components
494
- Place your JavaScript code inside of the default `app/javascript` folder. Use modules just as you would when using webpack alone. The difference here is that instead of mounting React components directly to an element using `React.render`, you **register your components to ReactOnRails and then mount them with helpers inside of your Rails views**.
495
-
496
- This is how to expose a component to the `react_component` view helper.
497
-
498
- ```javascript
499
- // app/javascript/packs/hello-world-bundle.js
500
- import HelloWorld from '../components/HelloWorld';
501
- import ReactOnRails from 'react-on-rails';
502
- ReactOnRails.register({ HelloWorld });
503
- ```
504
-
505
- #### Different Server-Side Rendering Code (and a Server Specific Bundle)
506
-
507
- You may want different initialization for your server-rendered components. For example, if you have an animation that runs when a component is displayed, you might need to turn that off when server rendering. However, the `railsContext` will tell you if your JavaScript code is running client side or server side. So code that required a different server bundle previously may no longer require this. Note, check if `window` is defined has a similar effect.
508
-
509
- If you want different code to run, you'd set up a separate webpack compilation file and you'd specify a different, server side entry file. ex. 'serverHelloWorld.jsx'. Note: you might be initializing HelloWorld with version specialized for server rendering.
510
-
511
- #### Renderer Functions
512
- A renderer function is a generator function that accepts three arguments: `(props, railsContext, domNodeId) => { ... }`. Instead of returning a React component, a renderer is responsible for calling `ReactDOM.render` to render a React component into the dom. Why would you want to call `ReactDOM.render` yourself? One possible use case is [code splitting](./docs/additional-reading/code-splitting.md).
513
-
514
- Renderer functions are not meant to be used on the server since there's no DOM on the server. Instead, use a generator function. Attempting to server render with a renderer function will cause an error.
515
-
516
- ## ReactOnRails View Helpers API
517
- Once the bundled files have been generated in your `app/assets/webpack` folder and you have registered your components, you will want to render these components on your Rails views using the included helper method, `react_component`.
518
-
519
- ### react_component
520
- ```ruby
521
- react_component(component_name,
522
- props: {},
523
- prerender: nil,
524
- trace: nil,
525
- replay_console: nil,
526
- raise_on_prerender_error: nil,
527
- id: nil,
528
- html_options: {})
529
- ```
530
-
531
- + **component_name:** Can be a React component, created using an ES6 class or a generator function that returns a React component (or, only on the server side, an object with shape { redirectLocation, error, renderedHtml }), or a "renderer function" that manually renders a React component to the dom (client side only).
532
- All options except `props, id, html_options` will inherit from your `react_on_rails.rb` initializer, as described [here](./docs/basics/configuration.md).
533
-
534
- + **general options:**
535
- + **props:** Ruby Hash which contains the properties to pass to the react object, or a JSON string. If you pass a string, we'll escape it for you.
536
- + **prerender:** enable server-side rendering of a component. Set to false when debugging!
537
- + **id:** Id for the div, will be used to attach the React component. This will get assigned automatically if you do not provide an id. Must be unique.
538
- + **html_options:** Any other HTML options get placed on the added div for the component. For example, you can set a class (or inline style) on the outer div so that it behaves like a span, with the styling of `display:inline-block`.
539
- + **trace:** set to true to print additional debugging information in the browser. Defaults to true for development, off otherwise. Only on the **client side** will you will see the `railsContext` and your props.
540
- + **options if prerender (server rendering) is true:**
541
- + **replay_console:** Default is true. False will disable echoing server-rendering logs to the browser. While this can make troubleshooting server rendering difficult, so long as you have the configuration of `logging_on_server` set to true, you'll still see the errors on the server.
542
- + **logging_on_server:** Default is true. True will log JS console messages and errors to the server.
543
- + **raise_on_prerender_error:** Default is false. True will throw an error on the server side rendering. Your controller will have to handle the error.
544
-
545
- ### react_component_hash
546
- `react_component_hash` is used to return multiple HTML strings for server rendering, such as for
547
- adding meta-tags to a page. It is exactly like react_component except for the following:
548
-
549
- 1. `prerender: true` is automatically added to options, as this method doesn't make sense for
550
- client only rendering.
551
- 2. Your JavaScript for server rendering must return an Object for the key `server_rendered_html`.
552
- 3. Your view code must expect an object and not a string.
23
+ -----
553
24
 
554
- Here is an example of ERB view code:
25
+ *These are the docs for React on Rails 13. To see the older docs: [v12](https://github.com/shakacode/react_on_rails/tree/12.6.0) and [v11](https://github.com/shakacode/react_on_rails/tree/11.3.0).*
555
26
 
556
- ```erb
557
- <% react_helmet_app = react_component_hash("ReactHelmetApp", prerender: true,
558
- props: { helloWorldData: { name: "Mr. Server Side Rendering"}},
559
- id: "react-helmet-0", trace: true) %>
560
- <% content_for :title do %>
561
- <%= react_helmet_app['title'] %>
562
- <% end %>
563
- <%= react_helmet_app["componentHtml"] %>
564
- ```
565
-
566
- And here is the JavaScript code:
567
-
568
- ```js
569
- export default (props, _railsContext) => {
570
- const componentHtml = renderToString(<ReactHelmet {...props} />);
571
- const helmet = Helmet.renderStatic();
572
-
573
- const renderedHtml = {
574
- componentHtml,
575
- title: helmet.title.toString(),
576
- };
577
- return { renderedHtml };
578
- };
579
-
580
- ```
581
-
582
- ### redux_store
583
- #### Controller Extension
584
- Include the module `ReactOnRails::Controller` in your controller, probably in ApplicationController. This will provide the following controller method, which you can call in your controller actions:
27
+ #### About
28
+ React on Rails integrates Rails with (server rendering of) Facebook's [React](https://github.com/facebook/react) front-end framework.
585
29
 
586
- `redux_store(store_name, props: {})`
30
+ 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 ReScript (ReasonML). We also build React Native apps and Gatsby sites. See [our recent work](https://www.shakacode.com/recent-work) for examples of what we do. ShakaCode.com (HiChee.com) is [hiring developers that like working on open-source](https://www.shakacode.com/career/).
587
31
 
588
- + **store_name:** A name for the store. You'll refer to this name in 2 places in your JavaScript:
589
- 1. You'll call `ReactOnRails.registerStore({storeName})` in the same place that you register your components.
590
- 2. In your component definition, you'll call `ReactOnRails.getStore('storeName')` to get the hydrated Redux store to attach to your components.
591
- + **props:** Named parameter `props`. ReactOnRails takes care of setting up the hydration of your store with props from the view.
32
+ Are you interested in optimizing your webpack setup for React on Rails including code
33
+ splitting with [react-router](https://github.com/ReactTraining/react-router#readme) and
34
+ [loadable-components](https://loadable-components.com/) with server-side rendering for SEO and hot-reloading for developers?
35
+ We 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/). Several years later, Popmenu is serving millions of SSR requests per day with React on Rails.
592
36
 
593
- For an example, see [spec/dummy/app/controllers/pages_controller.rb](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/app/controllers/pages_controller.rb). Note: this is preferable to using the equivalent view_helper `redux_store` in that you can be assured that the store is initialized before your components.
37
+ Check out [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro/). For more information, feel free to contact Justin Gordon, [justin@shakacode.com](mailto:justin@shakacode.com), maintainer of React on Rails.
594
38
 
595
- #### View Helper
596
- `redux_store(store_name, props: {})`
39
+ # Documentation
597
40
 
598
- This method has the same API as the controller extension. **HOWEVER**, we recommend the controller extension instead because the Rails executes the template code in the controller action's view file (`erb`, `haml`, `slim`, etc.) before the layout. So long as you call `redux_store` at the beginning of your action's view file, this will work. However, it's an easy mistake to put this call in the wrong place. Calling `redux_store` in the controller action ensures proper load order, regardless of where you call this in the controller action. Note: you won't know of this subtle ordering issue until you server render and you find that your store is not hydrated properly.
41
+ See the documentation at **[shakacode.com/react-on-rails/docs](https://www.shakacode.com/react-on-rails/docs/)**.
599
42
 
600
- `redux_store_hydration_data`
43
+ ## Project Objective
601
44
 
602
- Place this view helper (no parameters) at the end of your shared layout so ReactOnRails will render the redux store hydration data. Since we're going to be setting up the stores in the controllers, we need to know where on the view to put the client-side rendering of this hydration data, which is a hidden div with a matching class that contains a data props. For an example, see [spec/dummy/app/views/layouts/application.html.erb](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/app/views/layouts/application.html.erb).
45
+ To provide a high performance framework for integrating Ruby on Rails with React via the [**Webpacker**](https://github.com/rails/webpacker) gem, especially regarding React Server-Side Rendering for better SEO and improved performance.
603
46
 
604
- #### Redux Store Notes
605
- Note: you don't need to initialize your redux store. You can pass the props to your React component in a "generator function." However, consider using the `redux_store` helper for the two following use cases:
47
+ ## Features and Why React on Rails?
606
48
 
607
- 1. You want to have multiple React components accessing the same store at once.
608
- 2. You want to place the props to hydrate the client side stores at the very end of your HTML so that the browser can render all earlier HTML first. This is particularly useful if your props will be large.
49
+ Given that `rails/webpacker` gem already provides basic React integration, why would you use "React on Rails"?
609
50
 
610
- ### server_render_js
611
- `server_render_js(js_expression, options = {})`
51
+ 1. Automatic configuration of what bundles are added to the page based on what React components are on the page. This results in faster browser loading time via smaller bundle sizes.
52
+ 1. Keep up with the latest changes of different versions of React. React 18 is supported.
53
+ 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.
54
+ Tight integration with [shakapacker](https://github.com/shakacode/shakapacker) (or it's predecessor [rails/webpacker](https://github.com/rails/webpacker)).
55
+ 1. Server-Side Rendering (SSR), often used for SEO crawler indexing and UX performance.
56
+ 1. [Automated optimized entry-point creation and bundle inclusion when placing a component on a page. With this feature, you no longer need to configure `javascript_pack_tags` and `stylesheet_pack_tags` on your layouts based on what’s shown. “It just works!”](https://www.shakacode.com/react-on-rails/docs/guides/file-system-based-automated-bundle-generation/)
57
+ 1. [Redux](https://github.com/reactjs/redux) and [React Router](https://github.com/ReactTraining/react-router#readme) integration with server-side-rendering.
58
+ 1. [Internationalization (I18n) and (localization)](https://www.shakacode.com/react-on-rails/docs/guides/i18n)
59
+ 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/).
60
+ 1. [ReScript Support](https://github.com/shakacode/rescript-react-on-rails-example).
612
61
 
613
- + js_expression, like 2 + 3, and not a block of js code. If you have more than one line that needs to be executed, wrap it in an [IIFE](https://en.wikipedia.org/wiki/Immediately-invoked_function_expression). JS exceptions will be caught, and console messages will be handled properly
614
- + Currently, the only option you may pass is `replay_console` (boolean)
62
+ See [Rails/Webpacker React Integration Options](https://www.shakacode.com/react-on-rails/docs/guides/rails-webpacker-react-integration-options) for comparisons to other gems.
615
63
 
616
- This is a helper method that takes any JavaScript expression and returns the output from evaluating it. If you have more than one line that needs to be executed, wrap it in an IIFE. JS exceptions will be caught and console messages handled properly.
64
+ ## Online demo
65
+ * See the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial) for an example of a live implementation and code.
66
+ * A deployed version of the project `spec/dummy` which demonstrates several uses of `react_on_rails` is available on heroku [through this link](https://ror-spec-dummy.herokuapp.com/)
617
67
 
618
- ## Multiple React Components on a Page with One Store
619
- You may wish to have 2 React components share the same the Redux store. For example, if your navbar is a React component, you may want it to use the same store as your component in the main area of the page. You may even want multiple React components in the main area, which allows for greater modularity. Also, you may want this to work with Turbolinks to minimize reloading the JavaScript. A good example of this would be something like a notifications counter in a header. As each notification is read in the body of the page, you would like to update the header. If both the header and body share the same Redux store, then this is trivial. Otherwise, we have to rely on other solutions, such as the header polling the server to see how many unread notifications exist.
68
+ ## ShakaCode Forum Premium Content
69
+ _Requires creating a free account._
620
70
 
621
- Suppose the Redux store is called `appStore`, and you have 3 React components that each needs to connect to a store: `NavbarApp`, `CommentsApp`, and `BlogsApp`. I named them with `App` to indicate that they are the registered components.
71
+ * [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)
72
+ * [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)
622
73
 
623
- You will need to make a function that can create the store you will be using for all components and register it via the `registerStore` method. Note: this is a **storeCreator**, meaning that it is a function that takes (props, location) and returns a store:
74
+ ## Prerequisites
624
75
 
625
- ```js
626
- function appStore(props, railsContext) {
627
- // Create a hydrated redux store, using props and the railsContext (object with
628
- // Rails contextual information).
629
- return myAppStore;
630
- }
76
+ Ruby on Rails >=5, rails/webpacker >= 4.2 or shakapacker > 6, Ruby >= 2.7
631
77
 
632
- ReactOnRails.registerStore({
633
- appStore
634
- });
635
- ```
636
-
637
- When registering your component with React on Rails, you can get the store via `ReactOnRails.getStore`:
638
-
639
- ```js
640
- // getStore will initialize the store if not already initialized, so creates or retrieves store
641
- const appStore = ReactOnRails.getStore("appStore");
642
- return (
643
- <Provider store={appStore}>
644
- <CommentsApp />
645
- </Provider>
646
- );
647
- ```
78
+ # Support
648
79
 
649
- From your Rails view, you can use the provided helper `redux_store(store_name, props)` to create a fresh version of the store (because it may already exist if you came from visiting a previous page). Note: for this example, since we're initializing this from the main layout, we're using a generic name of `@react_props`. In other words, the Rails controller would set `@react_props` to the properties to hydrate the Redux store.
650
-
651
- **app/views/layouts/application.html.erb**
652
- ```erb
653
- ...
654
- <%= redux_store("appStore", props: @react_props) %>;
655
- <%= react_component("NavbarApp") %>
656
- yield
657
- ...
658
- ```
659
-
660
- Components are created as [stateless function(al) components](https://facebook.github.io/react/docs/reusable-components.html#stateless-functions). Since you can pass in initial props via the helper `redux_store`, you do not need to pass any props directly to the component. Instead, the component hydrates by connecting to the store.
661
-
662
- **_comments.html.erb**
663
- ```erb
664
- <%= react_component("CommentsApp") %>
665
- ```
666
-
667
- **_blogs.html.erb**
668
- ```erb
669
- <%= react_component("BlogsApp") %>
670
- ```
671
-
672
- *Note:* You will not be doing any partial updates to the Redux store when loading a new page. When the page content loads, React on Rails will rehydrate a new version of the store with whatever props are placed on the page.
673
-
674
- ## ReactOnRails JavaScript API
675
- See [ReactOnRails JavaScript API](docs/api/javascript-api.md).
676
-
677
- #### Using Rails built-in CSRF protection in JavaScript
678
-
679
- Rails has built-in protection for Cross-Site Request Forgery (CSRF), see [Rails Documentation](http://guides.rubyonrails.org/security.html#cross-site-request-forgery-csrf). To nicely utilize this feature in JavaScript requests, React on Rails provides two helpers that can be used as following for POST, PUT or DELETE requests:
680
-
681
- ```js
682
- import ReactOnRails from 'react-on-rails';
683
-
684
- // reads from DOM csrf token generated by Rails in <%= csrf_meta_tags %>
685
- csrfToken = ReactOnRails.authenticityToken();
686
-
687
- // compose Rails specific request header as following { X-CSRF-Token: csrfToken, X-Requested-With: XMLHttpRequest }
688
- header = ReactOnRails.authenticityHeaders(otherHeader);
689
- ```
690
-
691
- If you are using [jquery-ujs](https://github.com/rails/jquery-ujs) for AJAX calls, then these helpers are not needed because the [jquery-ujs](https://github.com/rails/jquery-ujs) library updates header automatically, see [jquery-ujs documentation](https://robots.thoughtbot.com/a-tour-of-rails-jquery-ujs#cross-site-request-forgery-protection).
692
-
693
- ## React Router
694
- [React Router](https://github.com/reactjs/react-router) is supported, including server-side rendering! See:
695
-
696
- 1. [React on Rails docs for react-router](./docs/additional-reading/react-router.md)
697
- 1. Examples in [spec/dummy/app/views/react_router](./spec/dummy/app/views/react_router) and follow to the JavaScript code in the [spec/dummy/client/app/startup/ServerRouterApp.jsx](spec/dummy/client/app/startup/ServerRouterApp.jsx).
698
- 1. [Code Splitting docs](./docs/additional-reading/code-splitting.md) for information about how to set up code splitting for server rendered routes.
699
-
700
- ## Error Handling
701
- * All errors from ReactOnRails will be of type ReactOnRails::Error.
702
- * Prerendering (server rendering) errors get context information for HoneyBadger and Sentry for easier debugging.
703
-
704
- ## Caching and Performance
705
- Consider fragment and http caching of pages that contain React on Rails components. See [Caching and Performance](./docs/additional-reading/caching-and-performance.md) for more details.
706
-
707
- ## Deployment
708
- * React on Rails puts the necessary precompile steps automatically in the rake precompile step. You can, however, disable this by setting certain values to nil in the [config/initializers/react_on_rails.rb](./docs/additional-reading/rspec_configuration.md).
709
- * `build_production_command`: Set to nil to turn off the precompilation of the js assets.
710
- * `config.symlink_non_digested_assets_regex`: Default is nil, turning off the setup of non-js assets. This should be nil except when when using Sprockets rather than Webpacker.
711
- * See the [Heroku Deployment](./docs/additional-reading/heroku-deployment.md) doc for specifics regarding Heroku. The information here should apply to other deployments.
712
-
713
- ## Integration with Node.js for Server Rendering
714
-
715
- If you want to use a node server for server rendering, [get in touch](mailto:justin@shakacode.com). ShakaCode has built a premium Node rendering server for React on Rails.
716
-
717
- ## Additional Documentation
718
- **Try out our [Documentation Gitbook](https://shakacode.gitbooks.io/react-on-rails/content/) for improved readability & reference.**
719
-
720
- + **Rails**
721
- + [Rails Assets](./docs/additional-reading/rails-assets.md)
722
- + [Rails Engine Integration](./docs/additional-reading/rails-engine-integration.md)
723
- + [Rails View Rendering from Inline JavaScript](./docs/additional-reading/rails_view_rendering_from_inline_javascript.md)
724
- + [RSpec Configuration](./docs/additional-reading/rspec-configuration.md)
725
- + [Turbolinks](./docs/additional-reading/turbolinks.md)
726
-
727
- + **Javascript**
728
- + [Node Dependencies, NPM, and Yarn](./docs/additional-reading/node-dependencies-and-npm.md)
729
- + [Babel](./docs/additional-reading/babel.md)
730
- + [React Router](./docs/additional-reading/react-router.md)
731
- + [React & Redux](./docs/additional-reading/react-and-redux.md)
732
- + [Webpack](./docs/additional-reading/webpack.md)
733
- + [Webpack Configuration](./docs/additional-reading/webpack.md)
734
- + [Webpack Cookbook](https://christianalfoni.github.io/react-webpack-cookbook/index.html)
735
- + [Developing with the Webpack Dev Server](docs/additional-reading/webpack-dev-server.md)
736
- + [Node Server Rendering](./docs/additional-reading/node-server-rendering.md)
737
- + [Server Rendering Tips](./docs/additional-reading/server-rendering-tips.md)
738
- + [Code Splitting](./docs/additional-reading/code-splitting.md)
739
- + [AngularJS Integration and Migration to React on Rails](./docs/additional-reading/angular-js-integration-migration.md)
740
- + [Webpack, the Asset Pipeline, and Using Assets w/ React](./docs/additional-reading/rails-assets-relative-paths.md)
741
-
742
- + **Development**
743
- + [React on Rails Basic Installation Tutorial](./docs/tutorial.md) ([live demo](https://hello-react-on-rails.herokuapp.com))
744
- + [Installation Overview](./docs/basics/installation-overview.md)
745
- + [Configuration](./docs/basics/configuration.md)
746
- + [Migration from react-rails](./docs/basics/migrating-from-react-rails.md)
747
- + [Recommended Project Structure](./docs/additional-reading/recommended-project-structure.md)
748
- + [Generator Tips](./docs/basics/generator.md)
749
- + [Hot Reloading of Assets For Rails Development](./docs/additional-reading/hot-reloading-rails-development.md)
750
- + [Heroku Deployment](./docs/additional-reading/heroku-deployment.md)
751
- + [Updating Dependencies](./docs/additional-reading/updating-dependencies.md)
752
- + [Caching and Performance](./docs/additional-reading/caching-and-performance.md)
753
-
754
- + **API**
755
- + [JavaScript API](./docs/api/javascript-api.md)
756
- + [Ruby API](./docs/api/ruby-api.md)
757
- + [Setting up Hot Reloading during Rails Development, API docs](./docs/api/ruby-api-hot-reload-view-helpers.md)
758
-
759
- + **Misc**
760
- + [Upgrading](./docs/basics/upgrading-react-on-rails.md)
761
- + [Tips](./docs/additional-reading/tips.md)
762
- + [Changelog](./CHANGELOG.md)
763
- + [Projects](./PROJECTS.md)
764
- + [Shaka Code Style](./docs/coding-style/style.md)
765
- + [React on Rails, Slides](http://www.slideshare.net/justingordon/react-on-rails-v61)
766
- + [Code of Conduct](./docs/misc/code_of_conduct.md)
767
- + [The React on Rails Doctrine](https://medium.com/@railsonmaui/the-react-on-rails-doctrine-3c59a778c724)
768
- + [React on Rails, 2000+ 🌟 Stars](https://medium.com/shakacode/react-on-rails-2000-stars-32ff5cfacfbf#.6gmfb2gpy)
769
- + [Generator Testing](./docs/contributor-info/generator-testing.md)
770
- + [Linting](./docs/contributor-info/linters.md)
771
- + [Releasing](./docs/contributor-info/releasing.md)
772
- + **[CONTRIBUTING](CONTRIBUTING.md)**
773
-
774
- ## Demos
775
- + [www.reactrails.com](http://www.reactrails.com) with the source at [shakacode/react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial/).
776
- + [spec app](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy): Great simple examples used for our tests.
777
- ```
778
- cd spec/dummy
779
- bundle && yarn
780
- foreman start
781
- ```
782
-
783
- ## Dependencies
784
- + Ruby 2.1 or greater
785
- + Rails 3.2 or greater
786
- + Node 5.5 or greater
80
+ * [Click to join **React + Rails Slack**](https://reactrails.slack.com/join/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE).
81
+ - [**Subscribe**](https://app.mailerlite.com/webforms/landing/l1d9x5) for announcements of new releases of React on Rails and of our latest [blog articles](https://blog.shakacode.com) and tutorials.
82
+ - [Discussions](https://github.com/shakacode/react_on_rails/discussions): Post your questions regarding React on Rails
83
+ - **[forum.shakacode.com](https://forum.shakacode.com)**: Other discussions
84
+ - **[@railsonmaui on Twitter](https://twitter.com/railsonmaui)**
85
+ - *See [NEWS.md](https://github.com/shakacode/react_on_rails/tree/master/NEWS.md) for more notes over time.*
86
+ - 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.
787
87
 
788
88
  ## Contributing
789
- Bug reports and pull requests are welcome. This project is intended to be a welcoming space for collaboration, and contributors are expected to adhere to our version of the [Contributor Covenant Code of Conduct](docs/misc/code_of_conduct.md)).
790
-
791
- See [Contributing](CONTRIBUTING.md) to get started. See [contribution help wanted](https://github.com/shakacode/react_on_rails/labels/contributions%3A%20up%20for%20grabs%21).
792
-
793
- ## License
794
- The gem is available as open source under the terms of the [MIT License](./docs/LICENSE.md).
795
-
796
- ## Authors
797
- [The Shaka Code team!](http://www.shakacode.com/about/)
798
-
799
- The origins of the project began with the need to do a rich JavaScript interface for a ShakaCode's client. The choice to use Webpack and Rails is described in [Fast Rich Client Rails Development With Webpack and the ES6 Transpiler](http://www.railsonmaui.com/blog/2014/10/03/integrating-webpack-and-the-es6-transpiler-into-an-existing-rails-project/).
800
-
801
- The gem project started with [Justin Gordon](https://github.com/justin808/) pairing with [Samnang Chhun](https://github.com/samnang) to figure out how to do server rendering with Webpack plus Rails. [Alex Fedoseev](https://github.com/alexfedoseev) then joined in. [Rob Wise](https://github.com/robwise), [Aaron Van Bokhoven](https://github.com/aaronvb), and [Andy Wang](https://github.com/yorzi) did the bulk of the generators. Many others have [contributed](https://github.com/shakacode/react_on_rails/graphs/contributors).
802
-
803
- The gem was initially inspired by the [react-rails gem](https://github.com/reactjs/react-rails).
804
-
805
- # Thanks!
806
- The following companies support open source, and ShakaCode uses their products!
807
-
808
- * [JetBrains](https://www.jetbrains.com/)
809
- * [![2017-02-21_22-35-32](https://cloud.githubusercontent.com/assets/1118459/23203304/1261e468-f886-11e6-819e-93b1a3f17da4.png)](https://www.browserstack.com)
810
-
811
- *If you'd like to support React on Rails and have your company listed here, [get in touch](mailto:justin@shakacode.com).*
812
-
813
- ---
814
-
815
- ## Thank you from Justin Gordon and [ShakaCode](http://www.shakacode.com)
816
-
817
- Thank you for considering using [React on Rails](https://github.com/shakacode/react_on_rails).
818
-
819
- We at [ShakaCode](http://www.shakacode.com) are a small, boutique, remote-first application development company. We fund this project by:
820
-
821
- * Providing priority support and training for anything related to React + Webpack + Rails in our [Pro Support program](http://www.shakacode.com/work/shakacode-pro-support.pdf).
822
- * Building custom web and mobile (React Native) applications. We typically work with a technical founder or CTO and instantly provide a full development team including designers.
823
- * Migrating **Angular** + Rails to React + Rails. You can see an example of React on Rails and our work converting Angular to React on Rails at [egghead.io](https://egghead.io/browse/frameworks).
824
- * Augmenting your team to get your product completed more efficiently and quickly.
825
-
826
- My article "[Why Hire ShakaCode?](https://blog.shakacode.com/can-shakacode-help-you-4a5b1e5a8a63#.jex6tg9w9)" provides additional details about our projects.
827
-
828
- If any of this resonates with you, please email me, [justin@shakacode.com](mailto:justin@shakacode.com). I offer a free half-hour project consultation, on anything from React on Rails to any aspect of web or mobile application development for both consumer and enterprise products.
829
-
830
- We are **[currently looking to hire](http://www.shakacode.com/about/#work-with-us)** like-minded developers that wish to work on our projects, including [Hawaii Chee](https://www.hawaiichee.com).
831
89
 
832
- Aloha and best wishes from Justin and the ShakaCode team!
90
+ 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).
91
+
92
+ # Work with Us
93
+ ShakaCode is **[hiring passionate software engineers](http://www.shakacode.com/career)** to work on our projects, including [HiChee](https://hichee.com)!
94
+
95
+ # License
96
+
97
+ 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).
98
+
99
+ # Supporters
100
+
101
+ The following companies support our open source projects, and ShakaCode uses their products!
102
+
103
+ <br />
104
+ <br />
105
+
106
+ <a href="https://www.jetbrains.com">
107
+ <img src="https://user-images.githubusercontent.com/4244251/184881139-42e4076b-024b-4b30-8c60-c3cd0e758c0a.png" alt="JetBrains" height="120px">
108
+ </a>
109
+ <a href="https://scoutapp.com">
110
+ <picture>
111
+ <source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/4244251/184881147-0d077438-3978-40da-ace9-4f650d2efe2e.png">
112
+ <source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/4244251/184881152-9f2d8fba-88ac-4ba6-873b-22387f8711c5.png">
113
+ <img alt="ScoutAPM" src="https://user-images.githubusercontent.com/4244251/184881152-9f2d8fba-88ac-4ba6-873b-22387f8711c5.png" height="120px">
114
+ </picture>
115
+ </a>
116
+ <a href="https://controlplane.com">
117
+ <picture>
118
+ <img alt="Control Plane" src="https://github.com/shakacode/.github/assets/20628911/90babd87-62c4-4de3-baa4-3d78ef4bec25" height="120px">
119
+ </picture>
120
+ </a>
121
+ <br />
122
+ <a href="https://www.browserstack.com">
123
+ <picture>
124
+ <source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/4244251/184881122-407dcc29-df78-4b20-a9ad-f597b56f6cdb.png">
125
+ <source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/4244251/184881129-e1edf4b7-3ae1-4ea8-9e6d-3595cf01609e.png">
126
+ <img alt="BrowserStack" src="https://user-images.githubusercontent.com/4244251/184881129-e1edf4b7-3ae1-4ea8-9e6d-3595cf01609e.png" height="55px">
127
+ </picture>
128
+ </a>
129
+ <a href="https://railsautoscale.com">
130
+ <img src="https://user-images.githubusercontent.com/4244251/184881144-95c2c25c-9879-4069-864d-4e67d6ed39d2.png" alt="Rails Autoscale" height="55px">
131
+ </a>
132
+ <a href="https://www.honeybadger.io">
133
+ <img src="https://user-images.githubusercontent.com/4244251/184881133-79ee9c3c-8165-4852-958e-31687b9536f4.png" alt="Honeybadger" height="55px">
134
+ </a>
135
+ <a href="https://reviewable.io">
136
+ <img src="https://user-images.githubusercontent.com/20628911/230848305-c94510a4-82d7-468f-bf9f-eeb81d3f2ce0.png" alt="Reviewable" height="55px">
137
+ </a>