Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
logger.info(
`[WEBCUBE] [${requestId}] Rendering react app to ${
skipPreload || preloadedAppState
? 'string'
: 'collect info for preload store'
}... ${skipPreload ? '(preload is skipped)' : ''}`
);
try {
html = renderToString(
createElement(
StyleSheetManager,
{
sheet: sheet.instance,
},
createElement(
Loadable.Capture,
{
report: moduleName => modules.push(moduleName),
},
createElement(Entry, {
// https://reacttraining.com/react-router/web/guides/server-rendering
StaticRouter,
routerContext: context,
currentUrl: url,
hostname,
// https://github.com/supasate/connected-react-router/blob/master/FAQ.md#how-to-set-router-props-eg-basename-initialentries-etc
baseUrl,
i18n,
language,
reportPreloadInfo: !skipPreload
? info => {
Object.assign(renderInfo, info);
export default async function renderer (isServer = false, reactRenderer: any, preloadedState: any, req?: any, courses?: any, courses64?: any, stats?: any, isPhone?: any, isTablet?: any): Promise {
const history = isServer ? null : createBrowserHistory()
const store = initReducer(preloadedState, history)
let Capture: any
if (isServer) {
store.dispatch(setCourses(courses.map((course: any): any => course.toJSON()), false))
store.dispatch(setCourses64(courses64.map((course: any): any => course.toJSON()), false))
store.dispatch(setStats(stats))
if (isPhone) store.dispatch(mediaQuery(ScreenSize.SUPER_SMALL))
else if (isTablet) store.dispatch(mediaQuery(ScreenSize.SMALL))
Capture = require('react-loadable').Capture
}
const context = {}
const modules: any[] = []
const _jsx =
{
isServer
?
(
)} />
:
}