react_on_rails 2.3.0 → 3.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e35d64aa961c1e0fe508c3a7d8499b71f47f4e54
4
- data.tar.gz: 6c4de485031ad25a5322b2e922799f90d8d152dd
3
+ metadata.gz: 5b1502f7743d3d66004e5f876204f48c83e0420b
4
+ data.tar.gz: 7373d3222c3344a3985c702d0db0b6f8944c751b
5
5
  SHA512:
6
- metadata.gz: a43c74fcbd866357676a5b2916827728fb969384776a43d27a205eecd030058f829deb8e0ad2f9be7e29022c00083446326c0dad7ed7e3d5987633415754dbde
7
- data.tar.gz: 57336349e02ed9f17b03b4cd58586da206a6763b49862ade9d92dae6ace06e4805bded4e3401ca074ed04e94d552700c834917b49a1ad7e348817385adf03aa8
6
+ metadata.gz: 87f66844af24dcf212c4e6537f4d30bd18f387e1926a013cdc413ecbbbba60a07b043a00f769ebfb7b5bf3d2da649ec106e41b5181e13c6b180c0e895b0b7f41
7
+ data.tar.gz: b0fb62a1879309db5de7e3d830015b432eee48766579a5f74c3dd910d077d226330257f2051ee64690c721ae75fda5a94b948adfaaa6d8a0484076e026ee84da
data/.rubocop.yml CHANGED
@@ -38,18 +38,20 @@ Lint/AssignmentInCondition:
38
38
  Exclude:
39
39
  - 'spec/dummy/bin/spring'
40
40
 
41
- # Offense count: 2
42
41
  Lint/HandleExceptions:
43
42
  Exclude:
44
43
  - 'spec/dummy/bin/rails'
45
44
  - 'spec/dummy/bin/rake'
46
45
 
47
- # Offense count: 1
48
46
  Metrics/AbcSize:
49
- Max: 24
47
+ Max: 26
48
+
49
+ Metrics/CyclomaticComplexity:
50
+ Max: 7
51
+
52
+ Metrics/PerceivedComplexity:
53
+ Max: 10
50
54
 
51
- # Offense count: 1
52
- # Configuration parameters: CountComments.
53
55
  Metrics/ClassLength:
54
56
  Max: 114
55
57
 
@@ -57,18 +59,12 @@ Metrics/ParameterLists:
57
59
  Max: 5
58
60
  CountKeywordArgs: false
59
61
 
60
- # Offense count: 9
61
- # Configuration parameters: CountComments.
62
62
  Metrics/MethodLength:
63
63
  Max: 41
64
64
 
65
- # Offense count: 1
66
- # Configuration parameters: CountComments.
67
65
  Metrics/ModuleLength:
68
- Max: 150
66
+ Max: 180
69
67
 
70
- # Offense count: 3
71
- # Configuration parameters: AllowedVariables.
72
68
  Style/GlobalVars:
73
69
  Exclude:
74
70
  - 'spec/dummy/config/environments/development.rb'
data/CHANGELOG.md CHANGED
@@ -3,11 +3,36 @@ All notable changes to this project will be documented in this file. Items under
3
3
 
4
4
  Contributors: 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.
5
5
 
6
- ## [Unreleased]
6
+ ## [3.0.0-beta.1]
7
+ ##### Added
8
+ - Added helper `redux_store` and associated JavaScript APIs that allow multiple React components to use the same store. Thus, you initialize the store, with props, separately from the components.
9
+ - Added forman to gemspec in case new dev does not have it globally installed. [#248](https://github.com/shakacode/react_on_rails/pull/248)
10
+
11
+ ##### Breaking Change
12
+ - Calls to `react_component` should use a named argument of props. For example, change this:
13
+ ```ruby
14
+ <%= react_component("ReduxSharedStoreApp", {}, prerender: false, trace: true) %>
15
+ ```
16
+
17
+ to
18
+ ```ruby
19
+ <%= react_component("ReduxSharedStoreApp", props: {}, prerender: false, trace: true) %>
20
+ ```
21
+ You'll get a deprecation message to change this.
22
+ - Renamed `ReactOnRails.configure_rspec_to_compile_assets` to `ReactOnRails::TestHelper.configure_rspec_to_compile_assets`. The code has also been optimized to check for whether or not the compiled webpack bundles are up to date or not and will not run if not necessary. If you are using non-standard directories for your generated webpack assets (`app/assets/javascripts/generated` and `app/assets/stylesheets/generated`) or have additional directories you wish the helper to check, you need to update your ReactOnRails configuration accordingly. See [documentation](https://github.com/shakacode/react_on_rails/blob/master/docs/additional_reading/rspec_configuration.md) for how to do this. [#253](https://github.com/shakacode/react_on_rails/pull/253).
23
+
24
+ ##### Migration
25
+ - [spec/dummy/spec/rails_helper.rb](https://github.com/shakacode/react_on_rails/blob/master/spec%2Fdummy%2Fspec%2Frails_helper.rb#L36..38) for an example. Add this line to your `rails_helper.rb`:
26
+ ```ruby
27
+ RSpec.configure do |config|
28
+ # Ensure that if we are running js tests, we are using latest webpack assets
29
+ ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
30
+ ```
31
+ - Change view helper calls to react_component to use the named param of `props`.
7
32
 
8
33
  ## [2.3.0] - 2016-02-01
9
34
  ##### Added
10
- - Added polyfills for `setInterval` and `setTimeout` in case other libraries expect these to exist.
35
+ - Added polyfills for `setInterval` and `setTimeout` in case other libraries expect these to exist.
11
36
  - Added much improved debugging for errors in the server JavaScript webpack file.
12
37
  - See [#244](https://github.com/shakacode/react_on_rails/pull/244/) for these improvements.
13
38
 
@@ -134,7 +159,7 @@ Best done with Object destructing:
134
159
  ##### Fixed
135
160
  - Fix several generator related issues.
136
161
 
137
- [Unreleased]: https://github.com/shakacode/react_on_rails/compare/2.3.0...HEAD
162
+ [3.0.0-beta.1]: https://github.com/shakacode/react_on_rails/compare/2.3.0...3.0.0-beta.1
138
163
  [2.3.0]: https://github.com/shakacode/react_on_rails/compare/2.2.0...2.3.0
139
164
  [2.2.0]: https://github.com/shakacode/react_on_rails/compare/2.1.1...2.2.0
140
165
  [2.1.1]: https://github.com/shakacode/react_on_rails/compare/v2.1.0...2.1.1
data/README.md CHANGED
@@ -28,12 +28,12 @@ Please see [Getting Started](#getting-started) for how to set up your Rails proj
28
28
  + *Normal Mode (React component will be rendered on client):*
29
29
 
30
30
  ```erb
31
- <%= react_component("HelloWorldApp", @some_props) %>
31
+ <%= react_component("HelloWorldApp", props: @some_props) %>
32
32
  ```
33
33
  + *Server-Side Rendering (React component is first rendered into HTML on the server):*
34
34
 
35
35
  ```erb
36
- <%= react_component("HelloWorldApp", @some_props, prerender: true) %>
36
+ <%= react_component("HelloWorldApp", props: @some_props, prerender: true) %>
37
37
  ```
38
38
 
39
39
  + The `component_name` parameter is a string matching the name you used to globally expose your React component. So, in the above examples, if you had a React component named "HelloWorldApp," you would register it with the following lines:
@@ -50,7 +50,7 @@ Please see [Getting Started](#getting-started) for how to set up your Rails proj
50
50
 
51
51
  ```ruby
52
52
  # Rails View
53
- <%= react_component("HelloWorldApp", { name: "Stranger" })
53
+ <%= react_component("HelloWorldApp", props: { name: "Stranger" }) %>
54
54
  ```
55
55
 
56
56
  ```javascript
@@ -73,6 +73,7 @@ Please see [Getting Started](#getting-started) for how to set up your Rails proj
73
73
  + [Generator](#generator)
74
74
  - [Understanding the Organization of the Generated Client Code](#understanding-the-organization-of-the-generated-client-code)
75
75
  - [Redux](#redux)
76
+ - [Multiple React Components on a Page with One Store](#multiple-react-components-on-a-page-with-one-store)
76
77
  - [Using Images and Fonts](#using-images-and-fonts)
77
78
  - [Bootstrap Integration](#bootstrap-integration)
78
79
  + [Bootstrap via Rails Server](#bootstrap-via-rails-server)
@@ -122,7 +123,7 @@ We're definitely not doing that. With react_on_rails, webpack is mainly generati
122
123
  1. Add the following to your Gemfile and bundle install:
123
124
 
124
125
  ```ruby
125
- gem "react_on_rails", "~> 2.0.0"
126
+ gem "react_on_rails", "~> 3"
126
127
  ```
127
128
 
128
129
  2. See help for the generator:
@@ -163,7 +164,7 @@ That will install the latest version and update your package.json.
163
164
  ## How it Works
164
165
  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/javascripts/generated`, which are then loaded by sprockets. These generated bundle files have been added to your `.gitignore` for your convenience.
165
166
 
166
- Inside your Rails views, you can now use the `react_component` helper method provided by React on Rails.
167
+ 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 helper `redux_store` so that the store can be shared amongst multiple React components. Your best best is to scan the code inside of the [/spec/dummy](spec/dummy) sample app.
167
168
 
168
169
  ### Client-Side Rendering vs. Server-Side Rendering
169
170
  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`.
@@ -285,6 +286,56 @@ If you have used the `--redux` generator option, you will notice the familiar ad
285
286
 
286
287
  Note the organizational paradigm of "bundles". These are like application domains and are used for grouping your code into webpack bundles, in case you decide to create different bundles for deployment. This is also useful for separating out logical parts of your application. The concept is that each bundle will have it's own Redux store. If you have code that you want to reuse across bundles, including components and reducers, place them under `/client/app/lib`.
287
288
 
289
+ #### Multiple React Components on a Page with One Store
290
+ 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. In addition, you may want this to work with Turbolinks to minimize reloading the JavaScript. A good example of this would be something like an a notifications counter in a header. As each notifications 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.
291
+
292
+ Suppose the Redux store is called `appStore`, and you have 3 React components that each need to connect to a store: `NavbarApp`, `CommentsApp`, and `BlogsApp`. I named them with `App` to indicate that they are the registered components.
293
+
294
+ You will need to make 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 and returns a store:
295
+
296
+ ```
297
+ ReactOnRails.registerStore({
298
+ appStore
299
+ });
300
+ ```
301
+
302
+ When registering your component with React on Rails, you can get the store via `ReactOnRails.getStore`:
303
+
304
+ ```js
305
+ // getStore will initialize the store if not already initialized, so creates or retrieves store
306
+ const appStore = ReactOnRails.getStore("appStore");
307
+ return (
308
+ <Provider store={appStore}>
309
+ <CommentsApp />
310
+ </Provider>
311
+ );
312
+ ```
313
+
314
+ 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`. This means in this case that Rails controllers would set `@react_props` to the properties to hydrate the Redux store.
315
+
316
+ **app/views/layouts/application.html.erb**
317
+ ```erb
318
+ ...
319
+ <% redux_store("appStore", @react_props) %>;
320
+ <%= render_component("NavbarApp") %>
321
+ yield
322
+ ...
323
+ ```
324
+
325
+ 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.
326
+
327
+ **_comments.html.erb**
328
+ ```erb
329
+ <%= render_component("CommentsApp") %>
330
+ ```
331
+
332
+ **_blogs.html.erb**
333
+ ```erb
334
+ <%= render_component("BlogsApp") %>
335
+ ```
336
+
337
+ *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.
338
+
288
339
  ### Using Images and Fonts
289
340
  The generator has amended the folders created in `client/assets/` to Rails's asset path. We recommend that if you have any existing assets that you want to use with your client code, you should move them to these folders and use webpack as normal. This allows webpack's development server to have access to your assets, as it will not be able to see any assets in the default Rails directories which are above the `/client` directory.
290
341
 
@@ -7,30 +7,31 @@ require "react_on_rails/prerender_error"
7
7
  module ReactOnRailsHelper
8
8
  # react_component_name: can be a React component, created using a ES6 class, or
9
9
  # React.createClass, or a
10
- # `generator function` that returns a React component
11
- # using ES6
12
- # let MyReactComponentApp = (props) => <MyReactComponent {...props}/>;
13
- # or using ES5
14
- # var MyReactComponentApp = function(props) { return <YourReactComponent {...props}/>; }
15
- # Exposing the react_component_name is necessary to both a plain ReactComponent as well as
16
- # a generator:
17
- # See README.md for how to "register" your react components.
18
- # See spec/dummy/client/app/startup/serverRegistration.jsx and
19
- # spec/dummy/client/app/startup/ClientRegistration.jsx for examples of this
20
- # props: Ruby Hash or JSON string which contains the properties to pass to the react object
10
+ # `generator function` that returns a React component
11
+ # using ES6
12
+ # let MyReactComponentApp = (props) => <MyReactComponent {...props}/>;
13
+ # or using ES5
14
+ # var MyReactComponentApp = function(props) { return <YourReactComponent {...props}/>; }
15
+ # Exposing the react_component_name is necessary to both a plain ReactComponent as well as
16
+ # a generator:
17
+ # See README.md for how to "register" your react components.
18
+ # See spec/dummy/client/app/startup/serverRegistration.jsx and
19
+ # spec/dummy/client/app/startup/ClientRegistration.jsx for examples of this
21
20
  #
22
- # options:
23
- # prerender: <true/false> set to false when debugging!
24
- # trace: <true/false> set to true to print additional debugging information in the browser
25
- # default is true for development, off otherwise
26
- # replay_console: <true/false> Default is true. False will disable echoing server rendering
27
- # logs to browser. While this can make troubleshooting server rendering difficult,
28
- # so long as you have the default configuration of logging_on_server set to
29
- # true, you'll still see the errors on the server.
30
- # raise_on_prerender_error: <true/false> Default to false. True will raise exception on server
31
- # if the JS code throws
32
- # Any other options are passed to the content tag, including the id.
33
- def react_component(component_name, props = {}, options = {})
21
+ # options:
22
+ # props: Ruby Hash or JSON string which contains the properties to pass to the react object. Do
23
+ # not pass any props if you are separately initializing the store by the `redux_store` helper.
24
+ # prerender: <true/false> set to false when debugging!
25
+ # trace: <true/false> set to true to print additional debugging information in the browser
26
+ # default is true for development, off otherwise
27
+ # replay_console: <true/false> Default is true. False will disable echoing server rendering
28
+ # logs to browser. While this can make troubleshooting server rendering difficult,
29
+ # so long as you have the default configuration of logging_on_server set to
30
+ # true, you'll still see the errors on the server.
31
+ # raise_on_prerender_error: <true/false> Default to false. True will raise exception on server
32
+ # if the JS code throws
33
+ # Any other options are passed to the content tag, including the id.
34
+ def react_component(component_name, options = {}, other_options = nil)
34
35
  # Create the JavaScript and HTML to allow either client or server rendering of the
35
36
  # react_component.
36
37
  #
@@ -38,6 +39,9 @@ module ReactOnRailsHelper
38
39
  # (re-hydrate the data). This enables react rendered on the client to see that the
39
40
  # server has already rendered the HTML.
40
41
  # We use this react_component_index in case we have the same component multiple times on the page.
42
+
43
+ options, props = parse_options_props(component_name, options, other_options)
44
+
41
45
  react_component_index = next_react_component_index
42
46
  react_component_name = component_name.camelize # Not sure if we should be doing this (JG)
43
47
  dom_id = if options[:id].nil?
@@ -50,11 +54,14 @@ module ReactOnRailsHelper
50
54
  # The reason is that React is smart about not doing extra work if the server rendering did its job.
51
55
  turbolinks_loaded = Object.const_defined?(:Turbolinks)
52
56
 
53
- data = { component_name: react_component_name,
54
- props: props,
55
- trace: trace(options),
56
- expect_turbolinks: turbolinks_loaded,
57
- dom_id: dom_id
57
+ props = {} if props.nil?
58
+
59
+ data = {
60
+ component_name: react_component_name,
61
+ props: props,
62
+ trace: trace(options),
63
+ expect_turbolinks: turbolinks_loaded,
64
+ dom_id: dom_id
58
65
  }
59
66
 
60
67
  component_specification_tag =
@@ -87,6 +94,25 @@ module ReactOnRailsHelper
87
94
  HTML
88
95
  end
89
96
 
97
+ # Separate initialization of store from react_component allows multiple react_component calls to
98
+ # use the same Redux store.
99
+ #
100
+ # store_name: name of the store, corresponding to your call to ReactOnRails.registerStores in your
101
+ # JavaScript code.
102
+ # props: Ruby Hash or JSON string which contains the properties to pass to the redux storea.
103
+ def redux_store(store_name, props = {})
104
+ redux_store_data = { store_name: store_name,
105
+ props: props }
106
+ @registered_stores ||= []
107
+ @registered_stores << redux_store_data
108
+
109
+ content_tag(:div,
110
+ "",
111
+ class: "js-react-on-rails-store",
112
+ style: ReactOnRails.configuration.skip_display_none ? nil : "display:none",
113
+ data: redux_store_data)
114
+ end
115
+
90
116
  def sanitized_props_string(props)
91
117
  props.is_a?(String) ? json_escape(props) : props.to_json
92
118
  end
@@ -144,6 +170,10 @@ module ReactOnRailsHelper
144
170
  @react_component_index += 1
145
171
  end
146
172
 
173
+ def props_string(props)
174
+ props.is_a?(String) ? props : props.to_json
175
+ end
176
+
147
177
  # Returns Array [0]: html, [1]: script to console log
148
178
  # NOTE, these are NOT html_safe!
149
179
  def server_rendered_react_component_html(options, props, react_component_name, dom_id)
@@ -155,12 +185,12 @@ module ReactOnRailsHelper
155
185
  # Make sure that we use up-to-date server-bundle
156
186
  ReactOnRails::ServerRenderingPool.reset_pool_if_server_bundle_was_modified
157
187
 
158
- # Since this code is not inserted on a web page, we don't need to escape.
159
- props_string = props.is_a?(String) ? props : props.to_json
188
+ # Since this code is not inserted on a web page, we don't need to escape props
160
189
 
161
190
  wrapper_js = <<-JS
162
191
  (function() {
163
- var props = #{props_string};
192
+ #{initialize_redux_stores}
193
+ var props = #{props_string(props)};
164
194
  return ReactOnRails.serverRenderReactComponent({
165
195
  name: '#{react_component_name}',
166
196
  domNodeId: '#{dom_id}',
@@ -196,6 +226,22 @@ module ReactOnRailsHelper
196
226
  # rubocop:enable Style/RaiseArgs
197
227
  end
198
228
 
229
+ def initialize_redux_stores
230
+ return "" unless @registered_stores.present?
231
+ declarations = "var reduxProps, store, storeGenerator;\n"
232
+ result = @registered_stores.each_with_object(declarations) do |redux_store_data, memo|
233
+ store_name = redux_store_data[:store_name]
234
+ props = props_string(redux_store_data[:props])
235
+ memo << <<-JS
236
+ reduxProps = #{props};
237
+ storeGenerator = ReactOnRails.getStoreGenerator('#{store_name}');
238
+ store = storeGenerator(reduxProps);
239
+ ReactOnRails.setStore('#{store_name}', store);
240
+ JS
241
+ end
242
+ result
243
+ end
244
+
199
245
  def raise_on_prerender_error(options)
200
246
  options.fetch(:raise_on_prerender_error) { ReactOnRails.configuration.raise_on_prerender_error }
201
247
  end
@@ -211,4 +257,37 @@ module ReactOnRailsHelper
211
257
  def replay_console(options)
212
258
  options.fetch(:replay_console) { ReactOnRails.configuration.replay_console }
213
259
  end
260
+
261
+ def parse_options_props(component_name, options, other_options)
262
+ other_options ||= {}
263
+ if options.is_a?(Hash) && options.key?(:props)
264
+ props = options[:props]
265
+ final_options = options.except(:props)
266
+ final_options.merge!(other_options) if other_options.present?
267
+ else
268
+ # either no props specified or deprecated
269
+ if other_options.present? || options.is_a?(String)
270
+ deprecated_syntax = true
271
+ else
272
+ options_has_no_reserved_keys =
273
+ %i(prerender trace replay_console raise_on_prerender_error).none? do |key|
274
+ options.key?(key)
275
+ end
276
+ deprecated_syntax = options_has_no_reserved_keys
277
+ end
278
+
279
+ if deprecated_syntax
280
+ puts "Deprecation: react_component now takes props as an explicity named parameter :props. "\
281
+ " Props as the second arg will be removed in a future release. Called for "\
282
+ "component_name: #{component_name}, controller: #{controller_name}, "\
283
+ "action: #{action_name}."
284
+ props = options
285
+ final_options = other_options
286
+ else
287
+ options ||= {}
288
+ final_options = options.merge(other_options)
289
+ end
290
+ end
291
+ [final_options, props]
292
+ end
214
293
  end
@@ -1,19 +1,23 @@
1
1
  # RSpec Configuration
2
2
  Because you will probably want to run RSpec tests that rely on compiled webpack assets (typically, your integration/feature specs where `js: true`), you will want to ensure you don't accidentally run tests on missing or stale webpack assets. If you did use stale Webpack assets, you will get invalid test results as your tests do not use the very latest JavaScript code.
3
3
 
4
- ReactOnRails provides a helper method called `configure_rspec_to_compile_assets`. Call this method from inside of the `RSpec.configure` block in your `spec/rails_helper.rb` file, passing the config as an argument.
4
+ ReactOnRails provides a helper method called `ReactOnRails::TestHelper.configure_rspec_to_compile_assets`. Call this method from inside of the `RSpec.configure` block in your `spec/rails_helper.rb` file, passing the config as an argument. See file [lib/react_on_rails/test_helper.rb](../../lib/react_on_rails/test_helper.rb) for more details. You can customize this to your particular needs by replacing any of the default components used by `ReactOnRails::TestHelper.configure_rspec_to_compile_assets`.
5
5
 
6
6
  ```ruby
7
7
  RSpec.configure do |config|
8
- # Next line will ensure that assets are built if webpack -w is not running
9
- ReactOnRails.configure_rspec_to_compile_assets(config)
8
+ # Next line will ensure that assets are built if webpack -w is not running to build the bundles
9
+ ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
10
10
  ```
11
11
 
12
- You can pass an RSpec metatag as an optional second parameter to this helper method if you want this helper to run on examples other than where `js: true` (default). The helper will compile webpack files at most once per test run.
12
+ You can pass an RSpec metatag as an optional second parameter to this helper method if you want this helper to run on examples other than where `js: true` (default). The helper will compile webpack files at most once per test run. The helper will not compile the webpack files unless they are out of date (stale).
13
13
 
14
- If you do not want to be slowed down by re-compiling webpack assets from scratch every test run, you can call `npm run build:client` (and `npm run build:server` if doing server rendering) to have webpack recompile these files in the background, which will be much faster. The helper looks for these processes and will abort recompiling if it finds them to be running.
14
+ Please take note of the following:
15
+ - This utility assumes your build tasks for the static generated files are `npm run build:client` and `npm run build:server` and do not have the `--watch` option enabled.
16
+ - By default, the webpack processes look for the `app/assets/javascripts/generated` and `app/assets/stylesheets/generated` folders. If these folders are missing, are empty, or contain files with `mtime`s older than any of the files in your `client` folder, the helper will recompile your assets. You can override this inside of `config/initializers/react_on_rails.rb` by passing an array of filepaths (relative to the root of the app) to the `generated_assets_dirs` configuration option.
15
17
 
16
- If you want to use a testing framework other than RSpec, we suggest you implement similar logic.
18
+ If you want to speed up the re-compiling process, you can call `npm run build:dev:client` (and `npm run build:dev:server` if doing server rendering) to have webpack run in "watch" mode and recompile these files in the background, which will be much faster when making incremental changes than compiling from scratch.
19
+
20
+ If you want to use a testing framework other than RSpec, please submit let us know on the changes you need to do and we'll update the docs.
17
21
 
18
22
  ![2016-01-27_02-36-43](https://cloud.githubusercontent.com/assets/1118459/12611951/7c56d070-c4a4-11e5-8a80-9615f99960d9.png)
19
23
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  * See [Turbolinks on Github](https://github.com/rails/turbolinks)
4
4
  * Currently support 2.5.x of Turbolinks. We plan to update to Turbolinks 5 soon.
5
+ * Turbolinks is currently included only via the Rails gem and the Rails manifest file rather than NPM. [Turbolinks Issue #658 ](https://github.com/rails/turbolinks/issues/658) discusses this.
5
6
 
6
7
  ## Why Turbolinks?
7
8
  As you switch between Rails HTML controller requests, you will only load the HTML and you will
@@ -55,3 +56,5 @@ TURBO: reactOnRailsPageLoaded
55
56
  ```
56
57
 
57
58
  We've noticed that Turbolinks doesn't work if you use the ruby gem version of jQuery and jQuery ujs. Therefore we recommend using the node packages instead. See the [tutorial app](https://github.com/shakacode/react-webpack-rails-tutorial) for how to accomplish this.
59
+
60
+ ![2016-02-02_10-38-07](https://cloud.githubusercontent.com/assets/1118459/12760060/6546e254-c999-11e5-828b-a8aaa473e5bd.png)