diff --git a/package-lock.json b/package-lock.json index 03afdf7..203a0db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "bluelib", - "version": "0.8.2", + "version": "0.11.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1435,12 +1435,26 @@ "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", "dev": true }, + "@types/prop-types": { + "version": "15.7.3", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz", + "integrity": "sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==" + }, "@types/q": { "version": "1.5.4", "resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.4.tgz", "integrity": "sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug==", "dev": true }, + "@types/react": { + "version": "16.9.38", + "resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.38.tgz", + "integrity": "sha512-pHAeZbjjNRa/hxyNuLrvbxhhnKyKNiLC6I5fRF2Zr/t/S6zS41MiyzH4+c+1I9vVfvuRt1VS2Lodjr4ZWnxrdA==", + "requires": { + "@types/prop-types": "*", + "csstype": "^2.2.0" + } + }, "@types/resolve": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz", @@ -1450,6 +1464,14 @@ "@types/node": "*" } }, + "@types/use-deep-compare-effect": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@types/use-deep-compare-effect/-/use-deep-compare-effect-1.2.0.tgz", + "integrity": "sha512-2uNqaSobMvUTGR7G72tUHDX+Kx341q25OuM0m2B6VID7eljIvYuDaFTKfmDnbvej67yEhCc35zA6dmIYriwOXA==", + "requires": { + "@types/react": "*" + } + }, "@webassemblyjs/ast": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.9.0.tgz", @@ -3995,6 +4017,11 @@ "cssom": "0.3.x" } }, + "csstype": { + "version": "2.6.10", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.10.tgz", + "integrity": "sha512-D34BqZU4cIlMCY93rZHbrq9pjTAQJ3U8S8rfBqjwHxkGPThWFjzZDQpgMJY0QViLxth6ZKYiwFBo14RdN44U/w==" + }, "cyclist": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cyclist/-/cyclist-1.0.1.tgz", @@ -4231,6 +4258,11 @@ "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", "dev": true }, + "dequal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-1.0.0.tgz", + "integrity": "sha512-/Nd1EQbQbI9UbSHrMiKZjFLrXSnU328iQdZKPQf78XQI6C+gutkFUeoHpG5J08Ioa6HeRbRNFpSIclh1xyG0mw==" + }, "des.js": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", @@ -12105,6 +12137,16 @@ "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==" }, + "use-deep-compare-effect": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/use-deep-compare-effect/-/use-deep-compare-effect-1.3.1.tgz", + "integrity": "sha512-ejL+Al+aeDyC9Sywx56ti4PtSwkf6BH27tEptMWF2cfO41/auG0nRRsArh6Vv5bUyBe3z7IyxmgQCK5nas70hg==", + "requires": { + "@babel/runtime": "^7.7.2", + "@types/use-deep-compare-effect": "^1.2.0", + "dequal": "^1.0.0" + } + }, "util": { "version": "0.11.1", "resolved": "https://registry.npmjs.org/util/-/util-0.11.1.tgz", diff --git a/package.json b/package.json index 017cf26..c4ee94b 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,15 @@ { "private": false, "name": "bluelib", - "version": "0.11.2", + "version": "0.11.3", "license": "AGPL-3.0-or-later", "source": "src/index.js", "main": "dist/index.js", "module": "dist/index.module.js", "unpkg": "dist/index.umd.js", - "files": ["dist/*"], + "files": [ + "dist/*" + ], "scripts": { "start": "preact watch", "dist": "git add . && cross-env-shell git commit -m \"$npm_package_version\" && git push && microbundle && npm publish && cross-env-shell hub release create -m \"$npm_package_version\" \"$npm_package_version\"" @@ -33,6 +35,7 @@ "react-syntax-highlighter": "^12.2.1", "showdown": "^1.9.1", "style-loader": "^1.2.1", + "use-deep-compare-effect": "^1.3.1", "webpack": "^4.43.0" } } diff --git a/src/hooks/useRoyalnetData.js b/src/hooks/useRoyalnetData.js index b9ffcdb..cf0beb5 100644 --- a/src/hooks/useRoyalnetData.js +++ b/src/hooks/useRoyalnetData.js @@ -1,13 +1,14 @@ import RoyalnetInstanceUrl from '../contexts/RoyalnetInstanceUrl'; -import {useContext, useEffect, useState} from 'preact/hooks'; +import {useContext, useState} from 'preact/hooks'; import {royalnetApiRequest} from '../utils/royalnetApiRequest'; +import useDeepCompareEffect from "use-deep-compare-effect"; export default function(method, path, body) { const instanceUrl = useContext(RoyalnetInstanceUrl); const [data, setData] = useState(undefined); - useEffect(() => { + useDeepCompareEffect(() => { royalnetApiRequest(instanceUrl, method, path, body).then(d => setData(d)); }, [instanceUrl, method, path, body]);