switched "render" to "hydrate"
This commit is contained in:
parent
701cc64062
commit
224d057b9a
4 changed files with 8 additions and 7 deletions
|
@ -1,11 +1,12 @@
|
||||||
|
import React from 'react';
|
||||||
import { renderToString } from 'react-dom/server';
|
import { renderToString } from 'react-dom/server';
|
||||||
import { createStore } from 'redux';
|
import { createStore } from 'redux';
|
||||||
import Reducer from '../react/reducers';
|
import Reducer from '../react/reducers';
|
||||||
import renderFullPage from './renderFullPage.js';
|
import { Provider } from 'react-redux';
|
||||||
|
|
||||||
import StaticRouter from 'react-router-dom/StaticRouter';
|
import StaticRouter from 'react-router-dom/StaticRouter';
|
||||||
import GAListener from '../react/components/GAListener';
|
import GAListener from '../react/components/GAListener';
|
||||||
import App from '../react/app';
|
import App from '../react/app';
|
||||||
|
import renderFullPage from './renderFullPage.js';
|
||||||
|
|
||||||
module.exports = (req, res) => {
|
module.exports = (req, res) => {
|
||||||
let context = {};
|
let context = {};
|
||||||
|
|
|
@ -14,7 +14,7 @@ module.exports = (html, preloadedState) => {
|
||||||
<script>
|
<script>
|
||||||
window.__PRELOADED_STATE__ = ${JSON.stringify(preloadedState).replace(/</g, '\\\u003c')}
|
window.__PRELOADED_STATE__ = ${JSON.stringify(preloadedState).replace(/</g, '\\\u003c')}
|
||||||
</script>
|
</script>
|
||||||
<script src="/static/bundle.js"></script>
|
<script src="/bundle/bundle.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { render } from 'react-dom';
|
import { hydrate } from 'react-dom';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
import { createStore, applyMiddleware, compose } from 'redux';
|
import { createStore, applyMiddleware, compose } from 'redux';
|
||||||
import { BrowserRouter } from 'react-router-dom';
|
import { BrowserRouter } from 'react-router-dom';
|
||||||
|
@ -35,7 +35,7 @@ if (preloadedState) {
|
||||||
sagaMiddleware.run(rootSaga);
|
sagaMiddleware.run(rootSaga);
|
||||||
|
|
||||||
// render the app
|
// render the app
|
||||||
render(
|
hydrate(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<GAListener>
|
<GAListener>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
const { site } = require('../config/speechConfig.js');
|
const { site } = require('../config/speechConfig.js');
|
||||||
// const handleRender = require('../helpers/handleRender.jsx');
|
const handleRender = require('../helpers/handleRender.jsx');
|
||||||
|
|
||||||
module.exports = (app) => {
|
module.exports = (app) => {
|
||||||
// route for the home page
|
// route for the home page
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.status(200).render('index');
|
handleRender(req, res);
|
||||||
});
|
});
|
||||||
// route to display login page
|
// route to display login page
|
||||||
app.get('/login', (req, res) => {
|
app.get('/login', (req, res) => {
|
||||||
|
|
Loading…
Reference in a new issue