Files
suwayomi-material-you-webui/webUI/react/src/screens/Sources.tsx

22 lines
587 B
TypeScript
Raw Normal View History

2021-01-19 14:47:07 +03:30
import React, { useEffect, useState } from 'react';
import SourceCard from '../components/SourceCard';
export default function Sources() {
let mapped;
const [sources, setSources] = useState<ISource[]>([]);
useEffect(() => {
fetch('http://127.0.0.1:4567/api/v1/source/list')
.then((response) => response.json())
.then((data) => setSources(data));
}, []);
if (sources.length === 0) {
mapped = <h3>wait</h3>;
} else {
mapped = sources.map((it) => <SourceCard source={it} />);
}
return <h2>{mapped}</h2>;
}