react_on_rails 12.0.0.pre.beta.2 → 12.0.2

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/.travis.yml +8 -4
  4. data/CHANGELOG.md +28 -19
  5. data/NEWS.md +5 -0
  6. data/README.md +79 -80
  7. data/SUMMARY.md +2 -2
  8. data/docs/additional-reading/converting-from-custom-webpack-config-to-rails-webpacker-config.md +10 -0
  9. data/docs/additional-reading/react-router.md +1 -1
  10. data/docs/additional-reading/recommended-project-structure.md +69 -0
  11. data/docs/additional-reading/server-rendering-tips.md +4 -1
  12. data/docs/api/javascript-api.md +3 -3
  13. data/docs/api/redux-store-api.md +2 -2
  14. data/docs/api/view-helpers-api.md +4 -4
  15. data/docs/basics/client-vs-server-rendering.md +2 -0
  16. data/docs/basics/configuration.md +21 -16
  17. data/docs/basics/deployment.md +2 -3
  18. data/docs/basics/heroku-deployment.md +24 -0
  19. data/docs/basics/hmr-and-hot-reloading-with-the-webpack-dev-server.md +62 -9
  20. data/docs/basics/i18n.md +3 -3
  21. data/docs/basics/installation-into-an-existing-rails-app.md +2 -7
  22. data/docs/basics/react-server-rendering.md +8 -5
  23. data/docs/basics/render-functions-and-railscontext.md +1 -1
  24. data/docs/basics/rspec-configuration.md +3 -4
  25. data/docs/basics/upgrading-react-on-rails.md +37 -18
  26. data/docs/basics/webpack-configuration.md +12 -22
  27. data/docs/misc/doctrine.md +1 -2
  28. data/docs/outdated/code-splitting.md +3 -3
  29. data/docs/outdated/how-react-on-rails-works.md +8 -4
  30. data/docs/outdated/manual-installation-overview.md +1 -1
  31. data/docs/outdated/rails-assets.md +0 -7
  32. data/docs/tutorial.md +6 -0
  33. data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +2 -0
  34. data/lib/react_on_rails/configuration.rb +45 -6
  35. data/lib/react_on_rails/helper.rb +8 -8
  36. data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +17 -0
  37. data/lib/react_on_rails/utils.rb +5 -1
  38. data/lib/react_on_rails/version.rb +1 -1
  39. data/lib/react_on_rails/webpacker_utils.rb +10 -4
  40. data/lib/tasks/assets.rake +38 -14
  41. data/package.json +1 -1
  42. data/rakelib/examples.rake +1 -1
  43. data/rakelib/lint.rake +1 -1
  44. data/rakelib/release.rake +1 -3
  45. data/react_on_rails.gemspec +1 -0
  46. data/yarn.lock +260 -109
  47. metadata +21 -6
  48. data/docs/basics/recommended-project-structure.md +0 -94
  49. data/docs/outdated/heroku-deployment.md +0 -86
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36f887cf3c39cbfcc07631658436609bc247785e98348aa8017cd188dbc6e4ba
4
- data.tar.gz: 359d97d280a4c6019fd954dd5d2e7f183388b4056a038703550ac08e5725ef06
3
+ metadata.gz: 2dacb7734da108abf8cf2a71bef68ba0b3049c2ef9d97aa46afc2ff9d53d4931
4
+ data.tar.gz: 66074b4e21e05482d185560c5dda2541b6fe48c65888d7ac20706b4fb1fdc97a
5
5
  SHA512:
6
- metadata.gz: 847d326b4b3e529d987b2143a5aeeb6293d4b70f52681368129acddcc87275bd81315b541b0e0b0e76390d3854e5bb0294b21acc2ef92f74b68595c55b00bf2b
7
- data.tar.gz: 9e0ce34d90525c0e1bfb7794e9381439632b4f93925642ce0e46d1c2ffefe6a3520dea2f3a442c305fd6289836152477fe24fe6bfb21c7bb1208b413981e0a12
6
+ metadata.gz: b8a29d39338fe7d8c79ec80c4b2cb95ddc3ecd280f2d2d70de9aa9fca92c01a1e5986c4c916580fd329ebcbce00ba25c3a9493d3e95d97167d3b49f66476b5da
7
+ data.tar.gz: 684c86dc869ee2c7453ed6f9c551c976efbbe817159cc1ef2ea0ec75369018a814e478eca896c9e8d4a23f44e4ba5a8875868fcddab3db31428457226423cdc0
@@ -10,6 +10,7 @@ AllCops:
10
10
  - '**/config.ru'
11
11
  - 'Gemfile'
12
12
  - '**/*.rb'
13
+ - '**/*.rake'
13
14
 
14
15
  Exclude:
15
16
  - 'vendor/**/*'
@@ -35,15 +35,19 @@ before_install:
35
35
 
36
36
  install:
37
37
  - travis_retry gem install bundler -v '>2'
38
- - travis_retry nvm install 13.9.0
38
+ - travis_retry nvm install 14
39
39
  - node -v
40
40
  - travis_retry npm i -g yarn
41
- - travis_retry bundle install
42
41
  - travis_retry yarn global add yalc
42
+ - travis_retry yalc add react-on-rails
43
+ - travis_retry yarn
44
+ - travis_retry bundle install
45
+ - travis_retry yarn run build
43
46
  - travis_retry yalc publish
44
- - travis_retry cd spec/dummy && yalc add react-on-rails
47
+ - cd spec/dummy
48
+ - travis_retry yalc add react-on-rails
45
49
  - travis_retry yarn
46
- - travis_retry cd ../.. && yarn run build
50
+ - cd ../..
47
51
  - bundle exec rake prepare_for_ci
48
52
 
49
53
  before_script:
@@ -11,22 +11,27 @@ We specialize in helping companies to quickly and efficiently move from versions
11
11
  ## Contributors
12
12
  Please follow the recommendations outlined at [keepachangelog.com](http://keepachangelog.com/). Please use the existing headings and styling as a guide, and add a link for the version diff at the bottom of the file. Also, please update the `Unreleased` link to compare to the latest release version.
13
13
 
14
- ## [Unreleased]
14
+ ## Versions
15
+ ### [Unreleased]
15
16
  Changes since last non-beta release.
16
17
 
17
18
  *Please add entries here for your pull requests that are not yet released.*
19
+ ### [12.0.2] - 2020-07-09
20
+ #### 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).
18
22
 
19
- ## UPCOMING 12.0 RELEASE
23
+ ### [12.0.1] - 2020-07-09
24
+ #### Fixed
25
+ - Changed invocation of webpacker:clean to use a very large number of versions so it does not acidentally delete the server-bundle.js. [PR 1306](https://github.com/shakacode/react_on_rails/pull/1306) by By [justin808](https://github.com/justin808).
20
26
 
21
- #### Improved
22
- ### [12.0.0.pre.beta.2]
23
- * Changed the precompile task to use the rails/webpacker one by default
27
+ ### [12.0.0] - 2020-07-08
28
+ For upgrade instructions, see [docs/basics/upgrading-react-on-rails.md](./docs/basics/upgrading-react-on-rails.md).
24
29
 
25
- ### [12.0.0.pre.beta.1]
26
- * Updated generators to use React hooks
27
-
28
- ### [12.0.0.pre.beta.0]
29
- Gem version: 12.0.0.pre.beta.0 and npm version 12.0.0-beta.0 released! Please try this out!
30
+ #### Major Improvements
31
+ 1. **React Hooks Support** for top level components
32
+ 2. **Typescript bindings**
33
+ 3. **rails/webpacker** "just works" with React on Rails by default.
34
+ 4. i18n support for generating a JSON file rather than a JS file.
30
35
 
31
36
  #### BREAKING CHANGE
32
37
  In order to solve the issues regarding React Hooks compatibility, the number of parameters
@@ -39,10 +44,14 @@ invoked to return the React component. In that case, you won't need to pass any
39
44
  See [docs/basics/upgrading-react-on-rails](./docs/basics/upgrading-react-on-rails.md#upgrading-to-v12)
40
45
  for details.
41
46
 
42
- * Requires the use of rails/webpacker helpers
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.
49
+ * Changed the precompile task to use the rails/webpacker one by default
50
+ * Updated generators to use React hooks
51
+ * Requires the use of rails/webpacker view helpers
43
52
  * If the webpacker webpack config files exist, then React on Rails will not override the default
44
- assets:precompile setup by rails/webpacker. The fix is to remove the JS files inside of config/webpack,
45
- like config/webpack/production.js.
53
+ assets:precompile setup by rails/webpacker. If you are not using the rails/webpacker setup for webpack,
54
+ then be sure to remove the JS files inside of config/webpack, like `config/webpack/production.js.`
46
55
  * Removed **env_javascript_include_tag** and **env_stylesheet_link_tag** as these are replaced by view helpers
47
56
  from rails/webpacker
48
57
  * Removal of support for old Rubies and Rails.
@@ -62,13 +71,12 @@ for details.
62
71
  * Added support to export locales in JSON format. New option added `i18n_output_format` which allows to
63
72
  specify locales format either `JSON` or `JS`. **`JSON` format is now the default.**
64
73
 
65
- Use this config setting to get the old behavior: config.i18n_output_format = 'js'
74
+ **Use this config setting to get the old behavior: config.i18n_output_format = 'js'**
66
75
 
67
76
  [PR 1271](https://github.com/shakacode/react_on_rails/pull/1271) by [ashgaliyev](https://github.com/ashgaliyev).
68
77
 
69
- #### Improved
70
78
  - 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).
71
- - Removed unnecessary restriction to keep the server bundle in the same directory with the client bundles. Rails/webpacker 4 has an advanced cleanup that will remove any files in the directory of other webpack files. Removing this restriction allows the server bundle to be created in a sibling directory. By [justin808](https://github.com/shakacode/react_on_rails/pull/1240).
79
+ - Removed restriction to keep the server bundle in the same directory with the client bundles. Rails/webpacker 4 has an advanced cleanup that will remove any files in the directory of other webpack files. Removing this restriction allows the server bundle to be created in a sibling directory. By [justin808](https://github.com/shakacode/react_on_rails/pull/1240).
72
80
 
73
81
  ### [11.3.0] - 2019-05-24
74
82
  #### Added
@@ -926,9 +934,10 @@ Best done with Object destructing:
926
934
  ##### Fixed
927
935
  - Fix several generator related issues.
928
936
 
929
- [Unreleased]: https://github.com/shakacode/react_on_rails/compare/12.0.0-beta.1...master
930
- [12.0.0.pre.beta.1]: https://github.com/shakacode/react_on_rails/compare/12.0.0-beta.0...12.0.0-beta.1
931
- [12.0.0.pre.beta.0]: https://github.com/shakacode/react_on_rails/compare/11.3.0...12.0.0-beta.0
937
+ [Unreleased]: https://github.com/shakacode/react_on_rails/compare/12.0.2...master
938
+ [12.0.2]: https://github.com/shakacode/react_on_rails/compare/12.0.1...12.0.2
939
+ [12.0.1]: https://github.com/shakacode/react_on_rails/compare/12.0.0...12.0.1
940
+ [12.0.0]: https://github.com/shakacode/react_on_rails/compare/11.3.0...12.0.0
932
941
  [11.3.0]: https://github.com/shakacode/react_on_rails/compare/11.2.2...11.3.0
933
942
  [11.2.2]: https://github.com/shakacode/react_on_rails/compare/11.2.1...11.2.2
934
943
  [11.2.1]: https://github.com/shakacode/react_on_rails/compare/11.1.8...11.2.1
data/NEWS.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  *We'll keep a history of the news. A few bullets at the top will also show on the [README.md](./README.md).*
4
4
 
5
+ * July 8, 2020: Release **v12**.
6
+ 1. **React Hooks Support** for top level components
7
+ 2. **Typescript bindings**
8
+ 3. **rails/webpacker** "just works" with React on Rails by default.
9
+ 4. i18n support for generating a JSON file rather than a JS file.
5
10
  * 2018-02-27: **Version 10.1.2** Supports the React API for ReactDOM.hydrate.
6
11
  * 2017-09-06: **VERSION 9.0.0 shipped!** This version depends on Webpacker directly. See [Upgrading React on Rails](./docs/basics/upgrading-react-on-rails.md) for more concise instructions on upgrading.
7
12
  * Always see the [CHANGELOG.md](./CHANGELOG.md) for the latest project changes.
data/README.md CHANGED
@@ -11,30 +11,39 @@
11
11
 
12
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
- *These are the docs for React on Rails 12, coming soon. To see the version 11 docs, [click here](https://github.com/shakacode/react_on_rails/tree/11.3.0).*
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
- **June 12, 2020**:
18
- 1. Gem version: 12.0.0.pre.beta.0 and npm version 12.0.0-beta.0 released! Please try this out!
19
- Major enhancements:
20
- 1. Typescript bindings
21
- 2. Proper support for React Hooks
22
- 3. i18n support for generating a JSON file rather than a JS file.
23
- 2. See Justin's RailsConf talk: [Webpacker, It-Just-Works, But How?](http://railsconf.com/2020/video/justin-gordon-webpacker-it-just-works-but-how).
24
-
25
- **April 2, 2020**:
17
+ **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
+
19
+ **July 8, 2020**: Release v12 of React on Rails.
20
+
21
+ **Major Improvements**
22
+
23
+ 1. **React Hooks Support** for top level components
24
+ 2. **Typescript bindings**
25
+ 3. **rails/webpacker** "just works" with React on Rails by default.
26
+ 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
+
31
+ * See Justin's RailsConf talk: [Webpacker, It-Just-Works, But How?](http://railsconf.com/2020/video/justin-gordon-webpacker-it-just-works-but-how).
26
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).
27
33
  * HMR is working with [Loadable Components](https://loadable-components.com) for a both amazing hot-reloading developer experience and great runtime performance. Please [email me](mailto:justin@shakacode.com) if you'd like to use [Loadable Components Code Splitting](https://loadable-components.com/docs/code-splitting/) to speed up your app by reducing your bundle sizes and lazily loading the code that's needed.
28
- * `react_on_rails` fully supports `rails/webpacker`. The example test app in `spec/dummy` was recently converted over to use rails/webpacker v4. It's a good example of how to leverage rails/webpacker's webpack configuration.
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.
29
35
 
30
36
  ---
31
37
 
32
38
  #### About
33
39
  React on Rails integrates Rails with (server rendering of) Facebook's [React](https://github.com/facebook/react) front-end framework.
34
40
 
35
- This project is sponsored by the software consulting firm [ShakaCode](https://www.shakacode.com). We focus on React front-ends, often with Ruby on Rails or Gatsby. The best way to see what we do is to see the details of [our recent work](https://www.shakacode.com/recent-work).
41
+ 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.
36
42
 
37
- Interested in optimizing your webpack setup for React on Rails including code splitting with react-router v4, webpack v4, and react-loadable with server side rendering? We just did this for Popmenu, [lowering Heroku costs 20-25% while getting a 73% decrease in average response times](https://www.shakacode.com/recent-work/popmenu/).
43
+ Interested in optimizing your webpack setup for React on Rails including code
44
+ splitting with [react-router](https://github.com/ReactTraining/react-router#readme),
45
+ and [loadable-components](https://loadable-components.com/) with server-side rendering?
46
+ We just did this for Popmenu, [lowering Heroku costs 20-25% while getting a 73% decrease in average response times](https://www.shakacode.com/recent-work/popmenu/).
38
47
 
39
48
  Feel free to contact Justin Gordon, [justin@shakacode.com](mailto:justin@shakacode.com), maintainer of React on Rails, for more information.
40
49
 
@@ -44,21 +53,20 @@ Feel free to contact Justin Gordon, [justin@shakacode.com](mailto:justin@shakaco
44
53
 
45
54
  ## Project Objective
46
55
 
47
- To provide an opinionated and optimal framework for integrating Ruby on Rails with React via the [**Webpacker**](https://github.com/rails/webpacker) gem especially in regards to React Server Rendering.
56
+ To provide a high performance framework for integrating Ruby on Rails with React via the [**Webpacker**](https://github.com/rails/webpacker) gem especially in regards to React Server-Side Rendering for better SEO and improved performance.
48
57
 
49
58
  ## Features and Why React on Rails?
50
59
 
51
- Given that rails/webpacker gem already provides basic React integration, why would you use "React on Rails"?
60
+ Given that `rails/webpacker` gem already provides basic React integration, why would you use "React on Rails"?
52
61
 
53
- 1. Server rendering, often used for SEO crawler indexing and UX performance, is not offered by rails/webpacker.
54
- 1. The easy passing of props directly from your Rails view to your React components rather than having your Rails view load and then make a separate request to your API.
55
- 1. [Redux](https://github.com/reactjs/redux) and [React Router](https://github.com/reactjs/react-router) integration with server-side-rendering.
62
+ 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
+ 1. Tight integration with [rails/webpacker](https://github.com/rails/webpacker).
64
+ 1. Server-Side Rendering (SSR), often used for SEO crawler indexing and UX performance, is not offered by `rails/webpacker`.
65
+ 1. [Redux](https://github.com/reactjs/redux) and [React Router](https://github.com/ReactTraining/react-router#readme) integration with server-side-rendering.
56
66
  1. [Internationalization (I18n) and (localization)](https://github.com/shakacode/react_on_rails/blob/master/docs/basics/i18n.md)
57
- 1. [RSpec Test Helpers Configuration](docs/basics/rspec-configuration.md) to ensure your Webpack bundles are ready for tests. _(and for [Minitest](docs/basics/minitest-configuration.md))._
58
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/).
59
68
  1. [Reason ML Support](https://github.com/shakacode/reason-react-on-rails-example).
60
69
 
61
-
62
70
  See the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial) for an example of a live implementation and code.
63
71
 
64
72
  ## ShakaCode Forum Premium Content
@@ -74,7 +82,7 @@ _Requires creating a free account._
74
82
 
75
83
  ## Prerequisites
76
84
 
77
- React on Rails supports older versions of Rails back to 3.x. Rails/webpacker requires version 4.2+.
85
+ Ruby on Rails >=5 and rails/webpacker 4.2+.
78
86
 
79
87
  ## Getting Started
80
88
 
@@ -89,23 +97,10 @@ Note, the best way to understand how to use ReactOnRails is to study a few simpl
89
97
 
90
98
  *See also [the instructions for installing into an existing Rails app](docs/basics/installation-into-an-existing-rails-app.md).*
91
99
 
92
- 1. Create a new Rails app:
93
-
94
- ``````bash
95
- $ rails new my-app --webpack=react
96
- $ cd my-app
97
- ``````
98
-
99
100
  2. Add the `react_on_rails` gem to Gemfile:
100
101
 
101
- ```ruby
102
- gem 'react_on_rails', '11.1.4' # Use the exact gem version to match npm version
103
- ```
104
-
105
- 3. Install the `react_on_rails` gem:
106
-
107
102
  ```bash
108
- $ bundle install
103
+ bundle add react_on_rails --strict
109
104
  ```
110
105
 
111
106
  4. Commit this to git (or else you cannot run the generator unless you pass the option `--ignore-warnings`).
@@ -113,13 +108,13 @@ Note, the best way to understand how to use ReactOnRails is to study a few simpl
113
108
  5. Run the generator:
114
109
 
115
110
  ```bash
116
- $ rails generate react_on_rails:install
111
+ rails generate react_on_rails:install
117
112
  ```
118
113
 
119
114
  6. Start the app:
120
115
 
121
116
  ```bash
122
- $ rails s
117
+ rails s
123
118
  ```
124
119
 
125
120
  7. Visit http://localhost:3000/hello_world.
@@ -138,14 +133,19 @@ Below is the line where you turn server rendering on by setting `prerender` to t
138
133
  <%= react_component("HelloWorld", props: @hello_world_props, prerender: false) %>
139
134
  ```
140
135
 
136
+ Note, if you got an error in your console regarding "ReferenceError: window is not defined",
137
+ then you need to edit `config/webpacker.yml` and set `hmr: false` and `inline: false`.
138
+ See [rails/webpacker PR 2644](https://github.com/rails/webpacker/pull/2644) for a fix for this
139
+ issue.
140
+
141
141
  ## Basic Usage
142
142
 
143
143
  ### Configuration
144
144
 
145
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
147
- * Set `compile: false` for all envs
148
- * Your `public_output_path` must match your Webpack configuration for `output` of your bundles.
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).
147
+ * 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
+ * Your `public_output_path` must match your custom Webpack configuration for `output` of your bundles.
149
149
  * Only set `cache_manifest` to `true` in your production env.
150
150
 
151
151
  ## Including your React Component on your Rails Views
@@ -170,7 +170,7 @@ Below is the line where you turn server rendering on by setting `prerender` to t
170
170
  ReactOnRails.register({ HelloWorld });
171
171
  ```
172
172
 
173
- 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.
173
+ 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. You may call `ReactOnRails.register` many times.
174
174
 
175
175
  - `@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:
176
176
 
@@ -179,7 +179,7 @@ Below is the line where you turn server rendering on by setting `prerender` to t
179
179
  <%= react_component("HelloWorld", props: { name: "Stranger" }) %>
180
180
  ```
181
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.
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
183
 
184
184
  ```js
185
185
  import React from 'react';
@@ -197,32 +197,6 @@ Below is the line where you turn server rendering on by setting `prerender` to t
197
197
 
198
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`.
199
199
 
200
- ## Fragment Caching
201
-
202
- Fragment caching is a [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro) feature. Fragment caching is a **HUGE** performance booster for your apps. Use the `cached_react_component` and `cached_react_component_hash`. The API is the same as `react_component` and `react_component_hash`, but for 2 differences:
203
-
204
- 1. The `cache_key` takes the same parameters as any Rails `cache` view helper.
205
- 1. The **props** are passed via a block so that evaluation of the props is not done unless the cache is broken. Suppose you put your props calculation into some method called `some_slow_method_that_returns_props`:
206
-
207
- ```ruby
208
- <%= cached_react_component("App", cache_key: [@user, @post], prerender: true) do
209
- some_slow_method_that_returns_props
210
- end %>
211
- ```
212
-
213
- Such fragment caching saves a ton of CPU work for your web server and greatly reduces the request time. It completely skips the evaluation costs of:
214
-
215
- 1. Database calls to compute the props.
216
- 2. Serialization the props values hash into a JSON string for evaluating JavaScript to server render.
217
- 3. Costs associated with evaluating JavaScript from your Ruby code.
218
- 4. Creating the HTML string containing the props and the server-rendered JavaScript code.
219
-
220
- Note, even without server rendering (without step 3 above), fragment caching is still effective.
221
-
222
- ## Integration with Node.js for Server Rendering
223
-
224
- Default server rendering is done by ExecJS. If you want to use a Node.js server for better performing server rendering, [email justin@shakacode.com](mailto:justin@shakacode.com). ShakaCode has built a premium Node rendering server that is part of [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro).
225
-
226
200
  ## Globally Exposing Your React Components
227
201
 
228
202
  For the React on Rails view helper `react_component` to use your React components, you will have to **register** them in your JavaScript code.
@@ -250,15 +224,15 @@ For details on techniques to use different code for client and server rendering,
250
224
 
251
225
  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:
252
226
 
253
- 1. You have access to the `railsContext`. See documentation for the railsContext in terms of why you might need it. You **need** a render function to access the `railsContext`.
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`.
254
228
  2. You can use the passed-in props to initialize a redux store or set up react-router.
255
229
  3. You can return different components depending on what's in the props.
256
230
 
257
- Note, the return value of a **render function** should be either a React Function or Class Component, or an object representing server rendering results.
231
+ Note, the return value of a **Render-Function** should be either a React Function or Class Component, or an object representing server rendering results.
258
232
 
259
233
  Do not return a React Element (JSX).
260
234
 
261
- ReactOnRails will automatically detect a registered render function by the fact that the function takes
235
+ ReactOnRails will automatically detect a registered Render-Function by the fact that the function takes
262
236
  more than 1 parameter. In other words, if you want the ability to provide a function that returns the
263
237
  React component, then you need to specify at least a second parameter. This is the `railsContext`.
264
238
  If you're not using this parameter, declare your function with the unused param:
@@ -272,13 +246,13 @@ const MyComponentGenerator = (props, _railsContext) => {
272
246
  }
273
247
  ```
274
248
 
275
- Thus, there is no difference between registering a React function or class Component versus a "render function."
249
+ Thus, there is no difference between registering a React Function Component or class Component versus a "Render-Function." Just call `ReactOnRails.register`.
276
250
 
277
- ## react_component_hash for render functions
251
+ ## react_component_hash for Render-Functions
278
252
 
279
- Another reason to use a render function is that sometimes in server rendering, specifically with React Router, you need to return the result of calling ReactDOMServer.renderToString(element). You can do this by returning an object with the following shape: { renderedHtml, redirectLocation, error }. Make sure you use this function with `react_component_hash`.
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`.
280
254
 
281
- For server rendering, if you wish to return multiple HTML strings from a render function, you may return an Object from your render function with a single top-level property of `renderedHtml`. Inside this Object, place a key called `componentHtml`, along with any other needed keys. An example scenario of this is when you are using side effects libraries like [React Helmet](https://github.com/nfl/react-helmet). Your Ruby code will get this Object as a Hash containing keys componentHtml and any other custom keys that you added:
255
+ 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:
282
256
 
283
257
  ```js
284
258
  { renderedHtml: { componentHtml, customKey1, customKey2} }
@@ -303,7 +277,6 @@ Browse the links in the [Summary Table of Contents](./SUMMARY.md)
303
277
  Here are some highly recommended next articles to read:
304
278
 
305
279
  1. [How React on Rails Works](docs/outdated/how-react-on-rails-works.md)
306
- 1. [Recommended Project Structure](./docs/basics/recommended-project-structure.md)
307
280
  1. [Webpack Configuration](./docs/basics/webpack-configuration.md)
308
281
  1. [View Helpers API](./docs/api/view-helpers-api.md)
309
282
  1. [Caching and Performance: React on Rails Pro](https://www.shakacode.com/react-on-rails-pro).
@@ -340,16 +313,42 @@ React on Rails Pro provides Node server rendering, fragment caching, code-splitt
340
313
 
341
314
  The [React on Rails Pro Support Plan](https://www.shakacode.com/react-on-rails-pro) can help!
342
315
 
343
- * Optimizing your webpack setup to Webpack v4 for React on Rails including code splitting with react-router v4, webpack v4, and react-loadable.
344
- * Upgrading your app to use the current Webpack setup that skips the Sprockets asset pipeline.
316
+ * Optimizing your webpack setup to the latest Webpack for React on Rails including code splitting with loadable-components.
317
+ * Upgrading your app to use the current `rails/webpacker` setup that skips the Sprockets asset pipeline.
345
318
  * Better performance client and server side.
346
- * Best practices based on over four years of React on Rails experience.
319
+ * Best practices based on over 6 years of React on Rails experience on many production projects.
347
320
  * Using [Reason](https://reasonml.github.io/) with (or without) React on Rails.
348
321
 
349
- ShakaCode can also help you with your custom software development needs. We specialize in marketplace and e-commerce applications that utilize both Rails and React. Because we own [HawaiiChee.com](https://www.hawaiichee.com), we can leverage that code for your app!
322
+ ShakaCode can also help you with your custom software development needs. We specialize in marketplace and e-commerce applications that utilize both Rails and React. Because we own [HiChee.com](https://hichee.com), we can leverage that code for your app!
350
323
 
351
324
  Please email Justin Gordon [justin@shakacode.com](mailto:justin@shakacode.com), the maintainer of React on Rails, for more information.
352
325
 
326
+ ### Fragment Caching
327
+
328
+ 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
+
330
+ 1. The `cache_key` takes the same parameters as any Rails `cache` view helper.
331
+ 1. The **props** are passed via a block so that evaluation of the props is not done unless the cache is broken. Suppose you put your props calculation into some method called `some_slow_method_that_returns_props`:
332
+
333
+ ```ruby
334
+ <%= cached_react_component("App", cache_key: [@user, @post], prerender: true) do
335
+ some_slow_method_that_returns_props
336
+ end %>
337
+ ```
338
+
339
+ Such fragment caching saves CPU work for your web server and greatly reduces the request time. It completely skips the evaluation costs of:
340
+
341
+ 1. Database calls to compute the props.
342
+ 2. Serialization the props values hash into a JSON string for evaluating JavaScript to server render.
343
+ 3. Costs associated with evaluating JavaScript from your Ruby code.
344
+ 4. Creating the HTML string containing the props and the server-rendered JavaScript code.
345
+
346
+ Note, even without server rendering (without step 3 above), fragment caching is still effective.
347
+
348
+ ## Integration with Node.js for Server Rendering
349
+
350
+ 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
+
353
352
  ## Testimonials for ShakaCode
354
353
  [HVMN Testimonial, by Paul Benigeri, October 12, 2018](./docs/testimonials/hvmn.md)
355
354
  > 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.
data/SUMMARY.md CHANGED
@@ -8,7 +8,6 @@
8
8
  + [How React on Rails Works](docs/outdated/how-react-on-rails-works.md)
9
9
  + [Client vs. Server Rendering](./docs/basics/client-vs-server-rendering.md)
10
10
  + [React Server Rendering](./docs/basics/react-server-rendering.md)
11
- + [Recommended Project Structure](./docs/basics/recommended-project-structure.md)
12
11
  + [Render-Functions and the RailsContext](docs/basics/render-functions-and-railscontext.md)
13
12
  + [Caching and Performance: React on Rails Pro](https://github.com/shakacode/react_on_rails/wiki).
14
13
  + [Deployment](docs/basics/deployment.md).
@@ -28,6 +27,7 @@
28
27
  + [Updating Dependencies](./docs/additional-reading/updating-dependencies.md)
29
28
  + [Manual Installation Overview](docs/outdated/manual-installation-overview.md)
30
29
  + [Upgrading from rails/webpacker v3 to v4](docs/additional-reading/upgrade-webpacker-v3-to-v4.md)
30
+ + [Recommended Project Structure](docs/additional-reading/recommended-project-structure.md)
31
31
 
32
32
  ## **Rails**
33
33
  + [Rails Engine Integration](./docs/additional-reading/rails-engine-integration.md)
@@ -45,7 +45,7 @@
45
45
  + [AngularJS Integration and Migration to React on Rails](./docs/additional-reading/angular-js-integration-migration.md)
46
46
 
47
47
  ## **Deployment**
48
- + [Heroku Deployment](docs/outdated/heroku-deployment.md)
48
+ + [Heroku Deployment](docs/basics/heroku-deployment.md)
49
49
  + [Elastic Beanstalk Deployment](./docs/additional-reading/elastic-beanstalk.md)
50
50
 
51
51
  ## Outdated Non-Webpack Docs