1
Fork 0
mirror of https://github.com/Steffo99/bluelib.git synced 2024-12-23 03:54:21 +00:00
This commit is contained in:
Steffo 2020-06-21 15:22:59 +02:00
parent 2cea4fe992
commit 4487925168
Signed by: steffo
GPG key ID: 896A80F55F7C97F0
2 changed files with 8 additions and 2 deletions

View file

@ -1,7 +1,7 @@
{ {
"private": false, "private": false,
"name": "bluelib", "name": "bluelib",
"version": "0.11.5", "version": "0.11.6",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"source": "src/index.js", "source": "src/index.js",
"main": "dist/index.js", "main": "dist/index.js",

View file

@ -9,9 +9,15 @@ export default function(method, path, body) {
const [data, setData] = useState(undefined); const [data, setData] = useState(undefined);
const [error, setError] = useState(undefined); const [error, setError] = useState(undefined);
function refresh() {
setData(undefined);
setError(undefined);
royalnetApiRequest(instanceUrl, method, path, body).then(d => setData(d)).catch((e => setError(e)));
}
useDeepCompareEffect(() => { useDeepCompareEffect(() => {
royalnetApiRequest(instanceUrl, method, path, body).then(d => setData(d)).catch((e => setError(e))); royalnetApiRequest(instanceUrl, method, path, body).then(d => setData(d)).catch((e => setError(e)));
}, [instanceUrl, method, path, body]); }, [instanceUrl, method, path, body]);
return [data, error]; return [data, error, refresh];
} }