Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
req: ctx.req || {},
res: ctx.res || {},
...initialProps,
});
props = plugins.apply('initialProps', {
initialValue: props,
});
} else {
// message activeRoute or getInitialProps not found
console.log(
!activeRoute
? `${pathname} activeRoute not found`
: `${pathname} activeRoute's getInitialProps function not found`,
);
}
const rootContainer = plugins.apply('rootContainer', {
initialValue: React.createElement(require('./router').default, props),
});
const htmlTemplateMap = {};
return {
htmlElement:
activeRoute && activeRoute.path
? htmlTemplateMap[activeRoute.path]
: '',
rootContainer,
matchPath: activeRoute && activeRoute.path,
g_initialData: props,
};
};
// using project react-dom version
initialValue: {},
});
// patch query object
const location = history.location
? { ...history.location, query: getUrlQuery(history.location.search) }
: {};
props = await activeRoute.component.getInitialProps({
route: activeRoute,
isServer: true,
location,
// only exist in server
req: ctx.req || {},
res: ctx.res || {},
...initialProps,
});
props = plugins.apply('initialProps', {
initialValue: props,
});
} else {
// message activeRoute or getInitialProps not found
console.log(
!activeRoute
? `${pathname} activeRoute not found`
: `${pathname} activeRoute's getInitialProps function not found`,
);
}
const rootContainer = plugins.apply('rootContainer', {
initialValue: React.createElement(require('./router').default, props),
});
const htmlTemplateMap = {};
return {
htmlElement:
render: function render(props) {
var childRoutes = renderRoutes(route.routes, extraProps, {
location: props.location
});
if (route.component) {
var compatProps = getCompatProps(_objectSpread({}, props, {}, extraProps));
var newProps = plugins.apply('modifyRouteProps', {
initialValue: _objectSpread({}, props, {}, extraProps, {}, compatProps),
args: {
route: route
}
});
var Component = route.component; // eslint-disable-next-line no-undef
if (__IS_BROWSER && Component.getInitialProps) {
var initialProps = plugins.apply('modifyInitialProps', {
initialValue: {}
});
Component = wrapWithInitialProps(Component, initialProps);
}
return _react.default.createElement(Component, _extends({}, newProps, {
route: route
var childRoutes = renderRoutes(route.routes, extraProps, {
location: props.location
});
if (route.component) {
var compatProps = getCompatProps(_objectSpread({}, props, {}, extraProps));
var newProps = plugins.apply('modifyRouteProps', {
initialValue: _objectSpread({}, props, {}, extraProps, {}, compatProps),
args: {
route: route
}
});
var Component = route.component; // eslint-disable-next-line no-undef
if (__IS_BROWSER && Component.getInitialProps) {
var initialProps = plugins.apply('modifyInitialProps', {
initialValue: {}
});
Component = wrapWithInitialProps(Component, initialProps);
}
return _react.default.createElement(Component, _extends({}, newProps, {
route: route
}), childRoutes);
} else {
return childRoutes;
}
}
});
const compatProps = getCompatProps({
...props,
...extraProps,
});
const newProps = plugins.apply('modifyRouteProps', {
initialValue: {
...props,
...extraProps,
...compatProps,
},
args: { route },
});
let { component: Component } = route;
// eslint-disable-next-line no-undef
if (__IS_BROWSER && Component.getInitialProps) {
const initialProps = plugins.apply('modifyInitialProps', {
initialValue: {},
});
Component = wrapWithInitialProps(Component, initialProps);
}
return (
{childRoutes}
);
} else {
return childRoutes;
}
}}
/>
render={props => {
// TODO: ssr StaticRoute context hook, handle 40x / 30x
const childRoutes = renderRoutes(route.routes, extraProps, {
location: props.location,
});
if (route.component) {
const compatProps = getCompatProps({
...props,
...extraProps,
});
const newProps = plugins.apply('modifyRouteProps', {
initialValue: {
...props,
...extraProps,
...compatProps,
},
args: { route },
});
let { component: Component } = route;
if (__IS_BROWSER && Component.getInitialProps) {
const initialProps = plugins.apply('modifyInitialProps', {
initialValue: {},
});
Component = wrapWithInitialProps(Component, initialProps);
}
return (
if (route.component) {
const compatProps = getCompatProps({
...props,
...extraProps,
});
const newProps = plugins.apply('modifyRouteProps', {
initialValue: {
...props,
...extraProps,
...compatProps,
},
args: { route },
});
let { component: Component } = route;
if (__IS_BROWSER && Component.getInitialProps) {
const initialProps = plugins.apply('modifyInitialProps', {
initialValue: {},
});
Component = wrapWithInitialProps(Component, initialProps);
}
return (
{childRoutes}
);
} else {
return childRoutes;
}
}}
/>
activeRoute.component.getInitialProps
) {
const initialProps = plugins.apply('modifyInitialProps', {
initialValue: {},
});
props = activeRoute.component.getInitialProps
? await activeRoute.component.getInitialProps({
route: activeRoute,
isServer: false,
location,
...initialProps,
})
: {};
}
}
const rootContainer = plugins.apply('rootContainer', {
initialValue: React.createElement(require('./router').default, props),
});
ReactDOM[window.g_useSSR ? 'hydrate' : 'render'](
rootContainer,
document.getElementById('root'),
);
};
const render = plugins.compose(