Passed
Pull Request — master (#140)
by
unknown
03:53
created

server/render.js   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 30
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 27
mnd 0
bc 0
fnc 1
dl 0
loc 30
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10

1 Function

Rating   Name   Duplication   Size   Complexity  
A render.js ➔ serverSideRender 0 19 1
1
import React from 'react';
2
import { Provider } from 'react-redux';
3
import { renderToString } from 'react-dom/server';
4
import createMemoryHistory from 'history/createMemoryHistory';
5
import { ConnectedRouter } from 'react-router-redux';
6
7
import setupStore from 'client/store';
8
import Router from 'client/router';
9
import template from 'client/index.html';
10
11
export default function serverSideRender() {
12
  const history = createMemoryHistory();
13
  const store = setupStore(history);
14
  const state = store.getState();
15
16
  const rendered = renderToString(
17
    <Provider store={store}>
18
      <ConnectedRouter history={history}>
19
        <Router />
20
      </ConnectedRouter>
21
    </Provider>,
22
  );
23
24
  const page = template
25
    .replace('<!-- CONTENT -->', rendered)
26
    .replace('"-- STORES --"', JSON.stringify(state));
27
28
  return page;
29
}
30