-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Had to work around no shared store support * See shakacode/react_on_rails#504
- Loading branch information
Showing
7 changed files
with
80 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
client/app/bundles/comments/startup/ClientRouterAppExpress.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Compare to ../ServerRouterApp.jsx | ||
// This | ||
import React from 'react'; | ||
import { Provider } from 'react-redux'; | ||
import ReactOnRails from 'react-on-rails'; | ||
import { Router, browserHistory } from 'react-router'; | ||
import routes from '../routes/routes'; | ||
import { syncHistoryWithStore } from 'react-router-redux'; | ||
|
||
// No need for this file if using shared stores, but to make this example work for simple express | ||
// server rendering, we only try get the shared store if the props were not passed. | ||
// See https://github.com/shakacode/react_on_rails/issues/504 | ||
import createStore from '../store/routerCommentsStore'; | ||
|
||
const RouterAppExpress = (_props, _railsContext) => { | ||
|
||
// See comment above | ||
const store = createStore(_props); | ||
|
||
// Create an enhanced history that syncs navigation events with the store | ||
const history = syncHistoryWithStore( | ||
browserHistory, | ||
store | ||
); | ||
|
||
return ( | ||
<Provider store={store}> | ||
<Router history={history} children={routes} /> | ||
</Provider> | ||
); | ||
}; | ||
|
||
ReactOnRails.register({ | ||
RouterAppExpress, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters