| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 5x 4x 4x 1x 3x 3x 1x 2x | /*
* © Jordan Tart https://github.com/jtart
* https://github.com/jtart/react-universal-app
*/
import { matchRoutes } from 'react-router-config';
const loadInitialData = async (url, routes) => {
const matchedRoutes = matchRoutes(routes, url);
if (matchedRoutes.length <= 0) {
throw new Error(`No route was found for ${url}.`);
}
const { route, match } = matchedRoutes[0];
if (!route.getInitialData) {
return {};
}
return route.getInitialData({ match });
};
export default loadInitialData;
|