Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function resolveAppProps(
routes: Array,
reducer: Reducer,
middleware: Array = []
): Promise {
const basename = window.APP_RUNTIME.appContext.basename || '';
const findMatches = getFindMatches(routes, basename);
const createStore = getBrowserCreateStore(findMatches, middleware);
const store = createStore(reducer, getInitialState(window.APP_RUNTIME));
// find the matched routes, and then resolve their components - mutate
// the route object so that the overall `routes` object contains
// resolved `component` properties for the current location
const resolveComponents = (): Promise => {
// get an array of matched routes
const matchedRoutes = findMatches(window.location);
// resolve components in parallel (AJAX chunk requests)
return Promise.all(
matchedRoutes.map(matchedRoute => {
if (matchedRoute.route.getComponent) {
return matchedRoute.route.getComponent();
}
return Promise.resolve(matchedRoute.route.component);
const initializeStore = resolvedRoutes => {
const createStore = getServerCreateStore(
getFindMatches(resolvedRoutes, appContext.basename),
middleware || [],
request
);
const initialState = { config: appContext };
return Promise.resolve(createStore(reducer, initialState));
};