Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

fix: load data without matched ids #656

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions packages/runtime/src/dataLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,15 @@ async function load(id: string, loader: GetData) {
* Get loaders by config of loaders.
*/
function getLoaders(loadersConfig: LoadersConfig, fetcher: Function): Loaders {
const context = (window as any).__ICE_APP_CONTEXT__ || {};
const matchedIds = context.matchedIds || [];

const loaders: Loaders = {};
matchedIds.forEach(id => {
const loaderConfig = loadersConfig[id];
if (loaderConfig) {
// If getData is an object, it is wrapped with a function.
loaders[id] = typeof loaderConfig === 'function' ? loadersConfig[id] : () => {
return fetcher(loaderConfig);
};
}

Object.keys(loadersConfig).forEach(id => {
const loader = loadersConfig[id];

// If getData is an object, it is wrapped with a function.
loaders[id] = typeof loader === 'function' ? loader : () => {
return fetcher(loader);
};
});

return loaders;
Expand Down