Skip to content

Commit 7ab33c6

Browse files
committed
refactor(ServerRendering) simpler server rendering assets
1 parent 58842d4 commit 7ab33c6

File tree

14 files changed

+160
-3936
lines changed

14 files changed

+160
-3936
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ where you will put your components
5151
//= require react_ujs
5252
//= require components
5353
```
54+
- create a `server_rendering.js` manifest file
5455

5556
## Usage
5657

@@ -185,8 +186,8 @@ _(It will also be mounted by the UJS on page load.)_
185186

186187
There are some requirements for this to work:
187188

188-
- `react-rails` must load your code. By convention, it uses `components.js`, which was created
189-
by the install task. This file must include your components _and_ their dependencies (eg, Underscore.js).
189+
- `react-rails` must load your code. By convention, it uses `server_rendering.js`, which was created
190+
by the install task. This file must include React, ReactDOMServer, your components _and_ their dependencies (eg, Underscore.js).
190191
- Your components must be accessible in the global scope.
191192
If you are using `.js.jsx.coffee` files then the wrapper function needs to be taken into account:
192193

@@ -210,7 +211,7 @@ MyApp::Application.configure do
210211
config.react.server_renderer_timeout ||= 20 # seconds
211212
config.react.server_renderer = React::ServerRendering::SprocketsRenderer
212213
config.react.server_renderer_options = {
213-
files: ["react-server.js", "components.js"], # files to load for prerendering
214+
files: ["server_rendering.js"], # files to load for prerendering
214215
replay_console: true, # if true, console.* will be replayed client-side
215216
}
216217
end

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace :react do
3434

3535
# With addons:
3636
copy_react_asset("#{environment}/react-browser-with-addons.js", "#{environment}-with-addons/react.js")
37-
copy_react_asset("#{environment}/react-server-with-addons.js", "#{environment}-with-addons/react-server.js")
37+
copy_react_asset("#{environment}/react-server.js", "#{environment}-with-addons/react-server.js")
3838

3939
addons = %w(
4040
addons-clone-with-props

0 commit comments

Comments
 (0)