File tree 5 files changed +21
-25
lines changed
5 files changed +21
-25
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ gem "rails-html-sanitizer"
37
37
# Use Unicorn as the app server
38
38
gem "unicorn"
39
39
40
+ gem "react_on_rails" , "~> 0.1.1"
41
+
40
42
gem "autoprefixer-rails"
41
43
42
44
# Use Capistrano for deployment
Original file line number Diff line number Diff line change 172
172
raindrops (0.15.0 )
173
173
rake (10.4.2 )
174
174
rdoc (4.2.0 )
175
+ react_on_rails (0.1.1 )
176
+ execjs (~> 2.5 )
177
+ rails (~> 4.2 )
175
178
rspec-core (3.3.2 )
176
179
rspec-support (~> 3.3.0 )
177
180
rspec-expectations (3.3.1 )
@@ -281,6 +284,7 @@ DEPENDENCIES
281
284
rails-html-sanitizer
282
285
rails_12factor
283
286
rainbow
287
+ react_on_rails (~> 0.1.1 )
284
288
rspec-rails
285
289
rubocop
286
290
ruby-lint
Original file line number Diff line number Diff line change 16
16
</ li >
17
17
</ ul >
18
18
< hr />
19
- < div id ="content "> </ div >
20
-
21
-
22
-
19
+ < div id ="content ">
20
+ <%= react_component ( 'App' ) %>
21
+ </ div >
Original file line number Diff line number Diff line change 1
- import $ from 'jquery' ;
2
-
3
1
import React from 'react' ;
4
2
import { Provider } from 'react-redux' ;
5
3
6
4
import CommentScreen from './components/CommentScreen' ;
7
5
import CommentStore from './stores/CommentStore' ;
8
6
9
- $ ( function onLoad ( ) {
10
- function render ( ) {
11
- if ( $ ( '#content' ) . length > 0 ) {
12
- React . render ( (
13
- < Provider store = { CommentStore } >
14
- { ( ) => < CommentScreen /> }
15
- </ Provider >
16
- ) , document . getElementById ( 'content' ) ) ;
17
- }
18
- }
19
-
20
- render ( ) ;
21
-
22
- // Next part is to make this work with turbo-links
23
- $ ( document ) . on ( 'page:change' , ( ) => {
24
- render ( ) ;
25
- } ) ;
26
- } ) ;
7
+ window . App = ( ) => {
8
+ const reactComponent = (
9
+ < Provider store = { CommentStore } >
10
+ { ( ) => < CommentScreen /> }
11
+ </ Provider >
12
+ ) ;
13
+ return reactComponent ;
14
+ } ;
Original file line number Diff line number Diff line change @@ -25,7 +25,10 @@ config.module.loaders.push(
25
25
// Next 2 lines expose jQuery and $ to any JavaScript files loaded after client-bundle.js
26
26
// in the Rails Asset Pipeline. Thus, load this one prior.
27
27
{ test : require . resolve ( 'jquery' ) , loader : 'expose?jQuery' } ,
28
- { test : require . resolve ( 'jquery' ) , loader : 'expose?$' }
28
+ { test : require . resolve ( 'jquery' ) , loader : 'expose?$' } ,
29
+
30
+ // React is necessary for the client rendering:
31
+ { test : require . resolve ( 'react' ) , loader : 'expose?React' }
29
32
) ;
30
33
module . exports = config ;
31
34
You can’t perform that action at this time.
0 commit comments