MCPcopy Index your code
hub / github.com/reactGo/reactGo / render

Function render

app/server.jsx:66–105  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

64 * and pass it into the Router.run function.
65 */
66export default function render(req, res) {
67
68 // Note that req.url here should be the full URL path from
69 // the original request, including the query string.
70 match({ routes, location: req.url }, (error, redirectLocation, renderProps) => {
71 if (error) {
72 res.status(500).send(error.message);
73 } else if (redirectLocation) {
74 res.redirect(302, redirectLocation.pathname + redirectLocation.search);
75 } else if (renderProps) {
76 fetchTopics(apiResult => {
77 const authenticated = req.isAuthenticated();
78 const store = configureStore({
79 // reducer: {initialState}
80 topic: {
81 topics: apiResult
82 },
83 user: {
84 authenticated: authenticated,
85 isWaiting: false
86 }
87 });
88 const initialState = store.getState();
89 const renderedContent = renderToString(
90 <Provider store={store}>
91 <RoutingContext {...renderProps} />
92 </Provider>);
93 const renderedPage = renderFullPage(renderedContent, initialState, {
94 title: headconfig.title,
95 meta: headconfig.meta,
96 link: headconfig.link
97 });
98 res.status(200).send(renderedPage);
99 });
100 } else {
101 res.status(404).send('Not Found');
102 }
103
104 });
105};

Callers 1

client.jsxFile · 0.85

Calls 3

fetchTopicsFunction · 0.85
configureStoreFunction · 0.85
renderFullPageFunction · 0.85

Tested by

no test coverage detected