mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 06:06:01 +00:00
16 lines
305 B
JavaScript
16 lines
305 B
JavaScript
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;
|
|
}
|