Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
,
req,
);
await getDataFromTree(App as any);
if (context.pageNotFound === true) {
res.status(404);
} else {
res.status(200);
}
const html = ReactDOMServer.renderToString(App as any);
// this comes after Html render otherwise we don't see fela rules generated
const appStyles = renderToSheetList(renderer);
// We need to tell Helmet to compute the right meta tags, title, and such.
const helmet = Helmet.renderStatic(); // Avoid memory leak while tracking mounted instances
if (context.url) {
res.writeHead(301, { Location: context.url });
res.end();
} else {
if (__DEV__ || !assetMap) {
assetMap = JSON.parse(fs.readFileSync(path.join(__FRONTEND_BUILD_DIR__, 'web', 'assets.json')).toString());
}
const apolloState = Object.assign({}, client.extract());
const reduxState = Object.assign({}, store.getState());
const env = {
...publicEnv,
};
.then(() => {
const reactAppString = isAmp
? renderToStaticMarkup(reactApp)
: renderToString(reactApp);
const felaMarkup = renderToSheetList(renderer);
const asyncState = asyncContext.getState();
// Generate the html res.
const state = store.getState();
const html = renderTemplate({
...Helmet.rewind(),
isAmp,
isBot,
root: reactAppString,
buildOn: BUILD_ON,
fela: felaMarkup,
scripts: isAmp ? js : [...js, assets.app.js].filter(x => x),
styles: isAmp ? css : [...css, assets.app.css].filter(x => x),
asyncState,
initialState: {
apollo: cache.data
// location: state.location,
static getInitialProps({ renderPage }) {
const serverRenderer = getFelaRenderer()
const page = renderPage(App => props => (
))
const sheetList = renderToSheetList(serverRenderer)
return {
...page,
sheetList,
}
}
static async getInitialProps(ctx) {
const renderer = getFelaRenderer()
const originalRenderPage = ctx.renderPage
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: App => props => ,
})
const initialProps = await Document.getInitialProps(ctx)
const sheetList = renderToSheetList(renderer)
return {
...initialProps,
sheetList,
}
}
template: template => {
const fela = renderToSheetList(renderer);
template.header.push(`
${fela
.map(
({ type, css, media }) =>
media
? `<style media="${media}" data-fela-type="${type}" type="text/css">${css}</style>`
: `<style data-fela-type="${type}" type="text/css">${css}</style>`
)
.join('\n')}
`);
return template;
},
};