Skip to content

Commit 46ab33a

Browse files
committed
refactor(ServerRendering) simpler server rendering assets
1 parent 76eb7e2 commit 46ab33a

File tree

14 files changed

+161
-3936
lines changed

14 files changed

+161
-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

@@ -177,8 +178,8 @@ _(It will also be mounted by the UJS on page load.)_
177178

178179
There are some requirements for this to work:
179180

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

@@ -202,7 +203,7 @@ MyApp::Application.configure do
202203
config.react.server_renderer_timeout ||= 20 # seconds
203204
config.react.server_renderer = React::ServerRendering::SprocketsRenderer
204205
config.react.server_renderer_options = {
205-
files: ["react-server.js", "components.js"], # files to load for prerendering
206+
files: ["server_rendering.js"], # files to load for prerendering
206207
replay_console: true, # if true, console.* will be replayed client-side
207208
}
208209
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)