Add caching to the useEntityPermission hook (#9064)

* Add caching to the useEntityPermission hook

Signed-off-by: Joon Park <joonp@spotify.com>

* Remove useRef

Signed-off-by: Joon Park <joonp@spotify.com>

* Use useSWR hook

Signed-off-by: Joon Park <joonp@spotify.com>
This commit is contained in:
Joon Park
2022-02-02 04:49:04 -06:00
committed by GitHub
parent 74298c1ae3
commit 6acc8f7db7
5 changed files with 62 additions and 49 deletions
+7
View File
@@ -0,0 +1,7 @@
---
'@backstage/plugin-catalog-react': patch
---
Add caching to the useEntityPermission hook
The hook now caches the authorization decision based on the permission + the entity, and returns the cache match value as the default `allowed` value while loading. This helps avoid flicker in UI elements that would be conditionally rendered based on the `allowed` result of this hook.