You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+5-2
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,10 @@ All notable changes to this project will be documented in this file. Items under
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
6
## [Unreleased]
7
+
8
+
## [6.2.0]
7
9
##### Added
8
-
- New API registerRenderer which allows a user to manually render their app to the DOM by [jtibbertsma](https://github.com/jtibbertsma)
10
+
- New API registerRenderer which allows a user to manually render their app to the DOM [#581](https://github.com/shakacode/react_on_rails/pull/581)by [jtibbertsma](https://github.com/jtibbertsma).
9
11
10
12
## [6.1.2] 2016-10-24
11
13
##### Fixed
@@ -376,7 +378,8 @@ Best done with Object destructing:
Copy file name to clipboardExpand all lines: README.md
+2
Original file line number
Diff line number
Diff line change
@@ -454,6 +454,7 @@ If you are using [jquery-ujs](https://github.com/rails/jquery-ujs) for AJAX call
454
454
455
455
1.[React on Rails docs for react-router](docs/additional-reading/react-router.md)
456
456
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).
457
+
1.[Code Splitting docs](docs/additional-reading/code-splitting.md) for information about how to set up code splitting for server rendered routes.
457
458
458
459
## Deployment
459
460
* Version 6.0 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](spec/dummy/config/initializers/react_on_rails.rb).
@@ -484,6 +485,7 @@ Node.js can be used as the backend for server-side rendering instead of [execJS]
484
485
+[Developing with the Webpack Dev Server](docs/additional-reading/webpack-dev-server.md)
485
486
+[Node Server Rendering](docs/additional-reading/node-server-rendering.md)
Copy file name to clipboardExpand all lines: docs/additional-reading/code-splitting.md
+24-9
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,11 @@ What is code splitting? From the webpack documentation:
8
8
9
9
Let's say you're requesting a page that needs to fetch a code chunk from the server before it's able to render. If you do all your rendering on the client side, you don't have to do anything special. However, if the page is rendered on the server, you'll find that React will spit out the following error:
10
10
11
-
```
12
-
Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
13
-
(client) <!-- react-empty: 1 -
14
-
(server) <div data-reactroot="
15
-
```
11
+
> Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
12
+
13
+
>(client) <!-- react-empty: 1 -
14
+
15
+
> (server) <div data-reactroot="
16
16
<!--This comment is here because the comment beginning on line 13 messes up Sublime's markdown parsing-->
17
17
18
18
Different markup is generated on the client than on the server. Why does this happen? When you register a component with `ReactOnRails.register`, react on rails will render the component as soon as the page loads. However, react-router renders a comment while waiting for the code chunk to be fetched from the server. This means that react will tear all of the server rendered code out of the DOM, and then rerender it a moment later once the code chunk arrives from the server, defeating most of the purpose of server rendering.
@@ -23,14 +23,14 @@ To prevent this, you have to wait until the code chunk is fetched before doing t
23
23
24
24
Here's an example of how you might use this in practice:
Note that you should not use `registerRenderer` on the server. Instead, use `register` like normal. For an example of how to set up an app for server rendering, see the [react router docs](react-router.md).
59
+
60
+
#### RouterAppRenderer.jsx
46
61
```jsx
47
62
importReactOnRailsfrom'react-on-rails';
48
63
importReactfrom'react';
@@ -82,7 +97,7 @@ Note that in page.html.erb, we call `react_component` in the exact same way as i
82
97
83
98
### Caveats
84
99
85
-
If you're going to try to do code splitting with server rendered routes, it's important that you have seperate webpack configurations for client and server. The code splitting happens for the client, but the server should one big file.
100
+
If you're going to try to do code splitting with server rendered routes, you'll probably need to use seperate route definitions for client and server to prevent code splitting from happening for the server bundle. The server bundle should be one file containing all the JavaScript code.
86
101
87
102
The reason is we do server rendering with ExecJS, which is not capable of doing anything asynchronous. See [this issue](https://github.com/shakacode/react_on_rails/issues/477) for a discussion.
0 commit comments