aboutsummaryrefslogtreecommitdiff
path: root/vnext/server
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-10-31 22:48:30 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:58 +0300
commit8887e1b51565b992f34c955c459125eb85b28483 (patch)
tree7fc8130f523014864e2d60aa9628e7a7ee7e7dd5 /vnext/server
parentfc96a9a206a825171da87a7f23cc2ea16b1d645d (diff)
`useVisitor` hook
Diffstat (limited to 'vnext/server')
-rw-r--r--vnext/server/middleware/renderer.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/vnext/server/middleware/renderer.js b/vnext/server/middleware/renderer.js
index a4b745f8..ca2ac2df 100644
--- a/vnext/server/middleware/renderer.js
+++ b/vnext/server/middleware/renderer.js
@@ -7,6 +7,7 @@ import App from '../../src/App';
import { getLinks } from '../sape';
import { StaticRouter } from 'react-router-dom/server';
+import { VisitorProvider } from '../../src/ui/VisitorContext';
const path = require('path');
const fs = require('fs');
@@ -49,9 +50,11 @@ const serverRenderer = async (req, res) => {
const propsData = `<script>window.__PROPS__="${toBinary(JSON.stringify(props))}";</script>${marker}`;
let didError = false;
const { pipe } = ReactDOMServer.renderToPipeableStream(
- <StaticRouter location={req.baseUrl} context={routerContext}>
- <App {...props} />
- </StaticRouter>
+ <VisitorProvider>
+ <StaticRouter location={req.baseUrl} context={routerContext}>
+ <App {...props} />
+ </StaticRouter>
+ </VisitorProvider>
, {
onShellReady() {
res.statusCode = didError ? 500 : 200;