This commit is contained in:
Jan Prochazka
2019-12-26 20:08:51 +01:00
parent c203758fd8
commit 63dc04027d
27 changed files with 2473 additions and 1110 deletions

15
web/src/useFetch.js Normal file
View File

@@ -0,0 +1,15 @@
import React from 'react';
import axios from 'axios'
export default function useFetch(url, defValue) {
const [value, setValue] = React.useState(defValue);
async function loadValue() {
setValue(await axios.get(url));
}
React.useEffect(() => {
loadValue();
}, [url]);
return value;
}