Fix bug
This commit is contained in:
parent
b307a12382
commit
b532a39be5
1 changed files with 10 additions and 8 deletions
|
@ -5,7 +5,7 @@ import {
|
||||||
handleResponse,
|
handleResponse,
|
||||||
Headline,
|
Headline,
|
||||||
ListContainer,
|
ListContainer,
|
||||||
ErrorMessage,
|
ErrorMessage
|
||||||
} from './elements';
|
} from './elements';
|
||||||
|
|
||||||
const useAppData = () => {
|
const useAppData = () => {
|
||||||
|
@ -15,10 +15,10 @@ const useAppData = () => {
|
||||||
? fetch('/data/apps.json').then(handleResponse)
|
? fetch('/data/apps.json').then(handleResponse)
|
||||||
: import('./data/apps.json')
|
: import('./data/apps.json')
|
||||||
)
|
)
|
||||||
.then((jsonResponse) => {
|
.then(jsonResponse => {
|
||||||
setAppData({ ...jsonResponse, error: false });
|
setAppData({ ...jsonResponse, error: false });
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
setAppData({ categories: [], apps: [], error: error.message });
|
setAppData({ categories: [], apps: [], error: error.message });
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -31,7 +31,7 @@ const useAppData = () => {
|
||||||
|
|
||||||
const AppList = () => {
|
const AppList = () => {
|
||||||
const {
|
const {
|
||||||
appData: { categories, apps, error },
|
appData: { categories, apps, error }
|
||||||
} = useAppData();
|
} = useAppData();
|
||||||
return (
|
return (
|
||||||
<ListContainer>
|
<ListContainer>
|
||||||
|
@ -45,10 +45,12 @@ const AppList = () => {
|
||||||
items={items}
|
items={items}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
{apps && (
|
||||||
<AppCategory
|
<AppCategory
|
||||||
name={categories ? 'Uncategorized apps' : null}
|
name={categories ? 'Uncategorized apps' : null}
|
||||||
items={apps}
|
items={apps}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</ListContainer>
|
</ListContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue